I have a website written with Meteor and external nodejs server that works with meteor's mongo. I create new documents in collection tradeOffers
on Meteor side and poll for new documents in this collection on external server (I use mongoose). Everything works fine except that mongoose returns documents without the '_id' property.
My code is something like this:
// Meteor
var TradeOffers = new Mongo.Collection('tradeOffers');
TradeOffers.insert({ ... });
// Mongoose
var tradeOfferSchema = new mongoose.Schema({ ... }, { collection: 'tradeOffers' });
var TradeOffer = mongoose.model('TradeOffer', tradeOfferSchema);
TradeOffer.find({}).exec(function(err, results) {
results.forEach(function(tradeOffer) {
console.log(tradeOffer._id); // undefined
});
});
I noticed that documents created in Meteor have '_id' field of type 'String' and documents created with mongoose have '_id' of type 'ObjectId'. But even if that's the problem, how do I solve it? I could not find any information. Thank you in advance.