-
Notifications
You must be signed in to change notification settings - Fork 182
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
MongoDB Insert deprecation (updated to insertOne/insertMany) #280
MongoDB Insert deprecation (updated to insertOne/insertMany) #280
Conversation
(node:30558) DeprecationWarning: collection.insert is deprecated. Use insertOne, insertMany or bulkWrite instead.
Codecov Report
@@ Coverage Diff @@
## master #280 +/- ##
==========================================
- Coverage 94.81% 94.57% -0.25%
==========================================
Files 6 6
Lines 386 387 +1
==========================================
Hits 366 366
- Misses 20 21 +1
Continue to review full report at Codecov.
|
Could you please do the same for count() |
How about updating the |
@faradaytrs most probably will, also group is going to be deprecated in favor of aggregation, i saw some of the tests spitting that out |
@mathieudutour that's a great idea! Will do that for backwards compatibility, however, will still keep insertOne/Many because of upwards compatibility with MongoDB itself. The final say in all this - of course - is the Monk maintainers. |
@RobertoMachorro apparently the |
@osban will do, but didn't see the warning? could you post more info about it? |
@RobertoMachorro here's the warning message: |
That works, thanks - just needed some context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's even remove the other 2 methods, they are superfluous
@mathieudutour that makes sense, i'll remove the insertOne/inserMany calls. Some of the mongodb-cli intuitiveness will be out, though. |
I'd say a single |
Implementation was requested in a way better approached from scratch.
@mathieudutour i'm making sure to match your code style, but I don't see a ternary operator anywhere on the source, do you prefer not to use them and go with regular if blocks? |
It internally maps to mongodb's insertOne or insertMany.
I do use ternaries, but maybe I’d write Or const colcall = arrayInsert
? args.col.insertMany
: args.col.insertOne On multiple lines It might be worth adding prettier to not have to care about it hahaha |
I had it like that originally (not including the parameters in the ternary), however, Node doesn't like it. I've seen that happen with functions that return a promise as opposed to a value:
|
According to the prototype, first argument must be a query: (query, opts, fn)
Thanks to all that can test, I'll start a count and find/fields update on a separate branch. |
Added bindings and updated tests for insertOne/insertMany. Monk already supports bulkWrite.
This addresses issue #276 .
(node:30558) DeprecationWarning: collection.insert is deprecated. Use insertOne, insertMany or bulkWrite instead.