Creating asynchronous requests in a loop to remove documents from the built-in collection:
_.each deletedItem, (item) ->
item.$delete()
Bug fixed:
{ message: 'No matching document found.', name: 'VersionError' }
While doing:
var resume = account.resumes.id(id);
resume.remove();
account.save(function (err, acct) {
console.log(err);
if(err) return next(err);
res.send(resume);
});
After registering account.resumesand viewing _idall resumes, the document that I am trying to find by id exists in the collection.
530e57a7503d421eb8daca65
FIND:
{ title: 'gggff', _id: 530e57a7503d421eb8daca65 }
AT:
[{ title: 'asddas', _id: 530e57a7503d421eb8daca61 }
{ title: 'gggff', _id: 530e57a7503d421eb8daca65 }
{ title: 'ewrs', _id: 530e57a7503d421eb8daca64 }]
I assume that this is due to the fact that I execute these requests asynchronously or that there is a problem with the version, but I have no idea how to resolve it.
It doesn't seem to me that when I register resumes, I can see resumewhich I am trying to find, but if I write:
log(account.resumes.id(id));
I get it undefined.
UPDATE
I found that my problem is with versions.
http://aaronheckmann.blogspot.com/2012/06/mongoose-v3-part-1-versioning.html
, , , .