Meteor Mongo inserting with Meteor ID’s instead of ObjectID's

I like to test my apps by opening a Meteor Mongo console and updating, inserting and removing documents. Is there a way to insert documents in the console and have it generate a Meteor ID instead of a Mongo ObjectID?

2 Likes

Does the Mongo repl let you define variables and functions? If so, you might be able to copy/paste the Random.id method into the repl and use it, though that would be slightly tedious.

Meteor is undefined. I tried ObjectId.toString() but it doesn’t work.

ObjectId().str.substr(0,17) works but it is rather inconvenient. Also it appears to repeat the same string.

1 Like