Closed ghost closed 8 years ago
I think I'm also seeing what @galdo666 is trying to say
When my collection has a idGeneration of 'MONGO', the doc._id
from after.insert(userId, doc)
is a string, and not the Mongo.ObjectID that's in the collection.
For example,
var collection1 = new Meteor.Collection('collection1', {idGeneration: 'MONGO'});
collection1.after.insert(function (userId, doc) {
collection1.direct.findOne({_id: doc._id});
});
throws the following error on insert
Exception in callback of async function: TypeError: value.id.copy is not a function
I20160814-21:56:54.109(-10)? at serializeObjectId (/Users/Marty/.meteor/packages/npm-mongo/.1.5.45.60a6cr++os+web.browser+web.cordova/npm/node_modules/bson/lib/bson/parser/serializer.js:252:14)
I believe this has to do with the updated function after (id, err)
in insert.js
in 0.8.3, which works when the collection's id generation is based on strings, but not when it's set to use Mongo.ObjectIds
. In this situation, doc._id
should be of type Mongo.ObjectID
.
If you'd like, I'll submit a PR with a test that reproduces this error and a fix that resolves it.
There is a different behavior between version 1.3 and 1.4 of Meteor, on after.insert the _id attribute of document is in mongo format, not in meteor format, it's correct?
Thanks