-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support passing mongoose specific params to queries. #70
Comments
I tested and found basically all mongo query/update operators like $push, $and, $elemMatch... are already available. Amazingly the only operator that's not working is $eq, the most simple one. |
@beeplin $eq is supported through our querying mechanism by just passing the object. Most other MongoDB query operators should work (but only with Mongoose and MongoDB) but if they are not part of our querying spec they will probably not work with other database adapters. This issue will address passing options (like |
Thanks for the explanation. I understand that mongo's finding options -- sort, limit, skip and fields selection are already supported in all adapters. For mongo's other two writing options, upsert and multi, since feathers' update\patch\remove only allows id as the first parameter, I don't think multi is necessary, but it would be nice to have an $upsert option. |
+1 for $upsert support. I was looking for a way to use it last month. While the new Wired Tiger engine in MongoDB does make for really amazing, ridiculous performance charts, if I can save a single query to the database, it will potentially have a big pay off... once the app reaches 40 thousand requests per second. 😃 |
@beeplin Feathers database adapters do support updating multiple resources if you set the id to |
oops missed that. Smart design! Thanks~ |
Also closed via #87 |
Hi @marshallswain I know it has been long ago, but did you figure out how to use |
Silly thought for upsert. Is there any value to do an optimistic update first, then a create should the update fail? What would the performance difference be compared to get then update or create? |
I am using the update-then-create-if-failed method. It can save a
So at least the get-then-update-or-create method should be improved like get-then-update-or-create-then-update-if-creation-fails. However, that's still problematical coz it may return wrong results if two users are trying to 'upsert' the same absent id -- we cannot guarantee the final result is determined by the 'upsert' called later since there are so many async writings to db and it is hard to maintain the proper sequence. That's why I think an atomic operator like 'upsert' is necessary in this case. |
I would think only the DB itself could provide an atomic upsert. |
Yes, and mongoDB does have this atomic upsert already -- just pass {upsert: true} as the third parameter when doing update. The problem here is the |
Setting params.mongodb or params.mongoose to |
@daffl yeah I just saw this line https://github.com/feathersjs/feathers-mongodb/blob/master/src/index.js#L36. Sorry that I didn't check earlier. |
I was having a hard time putting all these notes and docs together so in case anyone else is in the same boat here is the line from above with the upsert included.
|
Are you sure this is working? |
Oh sorry @daffl, I meant to post this in the mongodb version of this issue! (Too many tabs open!) This would be the proper way to use upsert for mongodb, right? |
It should be |
So to summarize (for mongoose this time):
|
Similar to this PR feathersjs-ecosystem/feathers-sequelize#27
The text was updated successfully, but these errors were encountered: