Maybe I'm completely wrong, but since projects that I start today, when I use meteor mongo to connect directly to the mongodb, and insert a record (with mycol.insert(..) the _id field is surrounded with ObjectId("12345555..."). When adding a record from code this is not the case. So, records added via Meteor Mongo are not recognised inside the app any longer. I have done this in the past so often... what's happening here?
That's the MONGO way and you see this because you are using the Mongo shell. Meteor defaults to a different method (cf below) which you see when you use it programmatically. Check Meteor docs on new Mongo.Collection
idGeneration String
The method of generating the _id fields of new documents in this collection. Possible values:
The default id generation technique is 'STRING'
In Meteor, if you write
Steffo = new Meteor.Collection("steffo", {idGeneration: 'STRING'});
this will result in entries
{ "foo" : "bar", "_id" : "68FWFNGRAuRt82pWy" }
If you use
Paul = new Meteor.Collection("paul", {idGeneration: 'MONGO'});
you'll get
{ "foo" : "bar", "_id" : ObjectId("26cfdb5f200adfa0b55a50d3" }
The latter happens when you use Mongo shell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With