This distinction apparently doesn't

This distinction apparently doesn't matter. new Document accepts DataModel explicitly because new DataModel does;
_initializeSource(data, options={}) {
if ( data instanceof DataModel ) data = data.toObject();
_initializeSource(data, options={}) {
if ( data instanceof DataModel ) data = data.toObject();
And then createDocuments explicitly accepts Documents but really accepts any compatible DataModel:
* @param {Array<object|Document>} data An array of data objects or existing Documents to persist.
* @param {Array<object|Document>} data An array of data objects or existing Documents to persist.
They actually don't do anything special in code it's just when the request is serialized the toJSON gets called and runs toObject. So basically both accept just the same. What does change is that after a certain point they're converted to an object. So I need a concept of ConstructorDataInInput and ConstructorDataAsAnObjectInLifecycle
11 Replies
LukeAbby
LukeAbbyOP4w ago
Threading because I anticipate conversation in this channel to go on
ChaosOS
ChaosOS4w ago
Nominally, the first is just the second in a union with this or whatever
LukeAbby
LukeAbbyOP4w ago
Not exactly it's DataModel<Schema, any, any> I suppose nominally it may be that but it accepts anything with a compatible schema
ChaosOS
ChaosOS4w ago
How often do we think that's going to come up?
LukeAbby
LukeAbbyOP4w ago
fair enough well it could come up if you do something like createDocuments([baseUser]) or something I point to baseUser specifically
ChaosOS
ChaosOS4w ago
I guess the distinction between say Actor and Actor.ConfiguredInstance might matter here?
LukeAbby
LukeAbbyOP4w ago
because I'm unsure if we should be switching it over to configured or not- yeah exactly you couldn't pass an actor or a base actor through these if it was this
ChaosOS
ChaosOS4w ago
My understanding is we were using BaseUser for all the permission related checks for circularity reasons
LukeAbby
LukeAbbyOP4w ago
Yeah, I recently tried switching again and hit that wall Maybe I can get it working in the future, I'll put it onto my todo list Do you think anyone would want to use something BESIDES User.ConfiguredInstance though
ChaosOS
ChaosOS4w ago
No don't think so
LukeAbby
LukeAbbyOP4w ago
Yeah okay I'll ticket it Looking in the circularity is a good idea anyways

Did you find this page helpful?