Been searching for an answer to, what I think, is a common question.
I'm using Mongoose and Step.js (for code control).
I'm iterating through a couple records, creating individual models and hoping to return the created IDs. This is for a RESTful service I'm implementing to bulk insert records. I didn't include all the parts that Step is doing.
Code looks roughly like this:
var group = this.group();
for (var i in records) {
model.create(records[i], group());
}
The group function is Step, waiting for all the records to save.
The problem is once each record is saved, I'm hoping that Mongoose will return the _id associated with each create. It's only returning a result of the record itself without the proper _id value.
I've attempted creating the ObjectId and saving the model, but that failed and isn't recommended by a lot of people in a number of forums.
Thanks.