Reputation: 3669
So, I created some simple app to play with Meteor in order to learn it, and everything worked just fine a few weeks ago. But, after coming back from my vacation I updated meteor to the latest version and now all of a sudden, the insert method creates some weird _id values.
Namely, I populate my database with random values and the _id values are all proper 24 character hexadecimal strings like 562a3d8de2547280a275088a and so on. For that I use mongo insert like this:
db.simpletable.insert({ name: 'LbDM7kbZf', email: '[email protected]', age: 32 });
db.simpletable.insert({ name: 'I6UClhz', email: '[email protected]', age: 44 });
db.simpletable.insert({ name: 'XeE3vNz', email: '[email protected]', age: 33 });
...
However, when I call the .insert from Meteor, the _id value is a 17 character string like this tJ3PXRmjderbu9oKF
and on the client I get the following error:
Uncaught Error: Invalid hexadecimal string for creating an ObjectID
I have no idea how to fix this or even where to look since the insert is painfully simple:
SimpleTable = new Mongo.Collection("simpletable");
SimpleTable.insert({
name: aObj.name,
email: aObj.email,
age: aObj.age
});
Upvotes: 3
Views: 579
Reputation: 3669
Adding , { idGeneration: 'MONGO' }
fixed the problem:
SimpleTable = new Mongo.Collection("simpletable", { idGeneration: 'MONGO' });
Thanks B. Clay Shannon for the link to https://stackoverflow.com/a/33228422
Upvotes: 5