I'm using mongoose to operate mongodb. Now, for testing, I want to insert some data into mongodb by native connection.
But here my main question is how to get the generated id after inserting?
I tried:
var mongoose = require('mongoose');
mongoose.connect('mongo://localhost/shuzu_test');
var conn = mongoose.connection;
var user = {
a: 'abc'
};
conn.collection('aaa').insert(user);
console.log('User:');
console.log(user);
But it prints:
{ a: 'abc' }
There is no _id field.