New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating multiple database entries at once #2404
Comments
I saw this http://stackoverflow.com/questions/21982571/updating-multiple-mongodb-records-in-sails-js#22003583 Now I can update multiple records with one value, But can I also make the values to be in an array and then update the record from the index of that array, for example as below var ids = [1, 2];
var pos = [4, 3]
Menuitem.update({id: ids},{position: pos}).exec(function(err, updatedRecords) {
if (err) {
return res.send({message: 'Could not update the records', err: err}, 500);
}
if (updatedRecords) {
return res.send({ records: updatedRecords }, 200);
} else {
return res.notFound('Records not found');
}
}); |
Oh, my! That would be something. But no, Waterline doesn't support this. Also, in the future please use the docs at http://sailsjs.org/#/documentation, and if you have a support question, post it on StackOverflow or our Google Group (this forum is for reporting bugs in the Sails core). |
According to the doc, the 2nd parameter of update() accepts [{}]. What does it mean? |
@sgress454 |
@sgress454 , if your answer is to check the documentation, you should really ensure that it addresses the issue. As the previous two posts show, the docs seem to indicate that this should work. |
@carpiediem That is very fair. I made the mistake of assuming the docs were correct. They usually are! I've updated them in the docs repo, and will see to it that the site is re-deployed soon. For future reference: The find criteria (first argument) for The values (second argument) for The Sails 1.0 docs are correct, at least 🙃 |
Cheers, thanks. |
Hi,
This is my function to update multiple database values at once
Checked the docs at https://github.com/balderdashy/waterline-docs/blob/master/query-methods.md#update-search-criteria--values--callback-
But could not find how to update multiple records at once.
http://stackoverflow.com/questions/26952705/update-multiple-records-at-once-using-sailsjs
The text was updated successfully, but these errors were encountered: