You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
Actually, I don't know if this will fly in your generic mixin which works for both sql and nosql but where would be a good place to handle upserts for mongo in your mixin with $currentDate and $setOnInsert so that folks don't have to worry about that stuff?
handle upserts for mongo in your mixin with $currentDate and $setOnInsert
💯 That might be a nice way to handle the upsert problem. In the generic sense there's no easy way unless query the database for the values before completing the upsert, something that invalidates the value of an upsert. However if those values were available without a query round trip and were the correct values to use I think it would make sense to create a shim.
I haven't done any investigation on this, so assuming those values are the right ones. I would probably create the following structure.
db.js
db/mongodb.js
Where the db.js file does the detection of the currently used database and provides either the mono module or no-op functions for other currently unsupported dbs; likely passing it the Model.
The monogodb file would probably just have one method exported, something like lookup which takes the ctx.instance (I don't think ctx.data would work) and adds the proper fields that would allow for an upsert with validation.
I'm still digesting your input ... in the meantime this snapshot represents the simplest set of from/to changes to get it done in code if the mixin doesn't take care of it, hoping to apply it to the mixin somehow.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This got me thinking if the mixin could auto-fill some timestamps for createdAt based on ObjectId ... exciting? see any merit? just ~meh?
The text was updated successfully, but these errors were encountered: