Meteor.Collection.ObjectID() vs MongoDB ObjectId()

Meteor.Collection.ObjectID() vs MongoDB ObjectId()

Asked on November 21, 2018 in Meteor.
Add Comment


  • 2 Answer(s)

    Using the Meteor method you can use the following:

        Meteor.Collection.ObjectID() is the same as MongoDB’s ObjectID, Its just under the Meteor.Collection name. It uses EJSON to hold object id’s in ordinary JSON to the client end. Because basically there are 2 databases with meteor

    Minimongo

        This is a sort of cache of mongodb on the client end. The data is downloaded from the main mongodb on the server to this one when the browser loads up. When changes are made they are pushed up to the server.

    Server MongoDB

        This is the original mongodb from 10gen on the server

    So because of these two databases Meteor needs to wrap mongodb functionality in Meteor.Collection and let you use the same code on both the client and server.

    By default meteor won’t use Object IDs it’ll use sort of random alphanumeric text. This is done so you can easily use ID’s in your URL’s and ID’s in your html attributes.

    If you do use new Meteor.Collection.ObjectID() you will get an ObjectID object that will use mongodb’s specification of ObjectID on the server end. The timestamp value in the Object ID isn’t held up but this shouldn’t really do any harm.

    Answered on November 21, 2018.
    Add Comment

    Try this,

        In the view of 0.9.1 Meteor suggesting to use Mongo.ObjectID instead of Meteor.Collection.ObjectID . Basically both are same. Check history.md for more changes in naming conventions.

    Answered on November 21, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.