I’ve been digging around in the MongoDB Node Native Driver source code for a basic node server that I’m building and I noticed some interesting things. I realize that Meteor’s Mongo.Collection
API is it’s own API, but at it’s core is the mongo node native driver.
What I found interesting was that collection.findOne
, collection.insert
, collection.update
and collection.remove
are all deprecated in the native driver. Instead of each of those, they give you a list of other methods you should use instead like collection.insertOne
, collection.deleteMany
or collection.updateMany
.
While I find collection.findOne
to be very useful and collection.insert
to be slightly more convenient to type than collection.insertOne
, I’m sure the team creating the database we are using has some good reasons for deprecating the old methods and adding these newer ones. Aside from the performance enhancements that they likely add, they could even help us write a little less code.
// Example:
const arr = [ ...someObjects ];
// Insert objects in an array like this
arr.forEach((obj) => {
SomeCollection.insert(obj);
});
// or like this
SomeCollection.insertMany(arr);
I know we can access these features from the raw collections, but I was just curious if MDG is going to deprecate their implementations of these collection methods and implement the newer ones since this is the way MongoDB is going. Anyone know if this is in the roadmap?