This object is in archive! 
ObjectId as an option for test data generator
Under Consideration
Would be nice to have an option to generate ObjectID field in test data generator dialog. Ideally I want to have an option to randomly spread all the generated objects between preselected set of IDs or between IDs from the other collection.
Simple use case - I want to generate 10K documents with userId property and assign those document userIds to lets say random userId from users collection.
I like this idea
The following code may be a little help.
const userIds=db.users.select("_id").limit(1000*10).map(it=>it._id); sampleDoc.userId= _.sample(userIds); // will return one item randomly from the userIds arrayThe following code may be a little help.
const userIds=db.users.select("_id").limit(1000*10).map(it=>it._id); sampleDoc.userId= _.sample(userIds); // will return one item randomly from the userIds arrayReplies have been locked on this page!