Insert a doc with _id as a String in node


#1

I noticed, when I insert documents in Meteor, it saves _id as "_id" : "kEdtp42GSupay8tf2".

But when I insert using nodejs it saves as "_id" : ObjectId("55e40c30422ba1aa2906f526") when using the following code:

MongoClient.connect('mongodb://localhost:3001/meteor', function(err, db) {
    if(err) throw err;

    var doc = { title: 'post6',
    			body: "6 Fake St"
				};

    db.collection('posts').insert(doc, {w:1}, function(err, doc) {
        if(err) throw err;

        console.dir(doc);

        db.close();
    });
});

How can I save "_id" : "kEdtp42GSupay8tf2". ?


#2

Hi, why in Nodejs, you don’t use this package : https://github.com/mondora/asteroid ?