So, I'm doing this app, where will I have menu items for the restaurant?
The owner should be able to navigate through the menu items.
This is my model menuitem.js contains
name, price, position
What is it. Super simple.
So, to move these elements, I will use jQuery UI Thus, the final product will be something very similar to this> http://jqueryui.com/sortable/
So, my goal is to save the position of each of these menu items in the database every time one of the menu items has been changed. So I thought Sails should have a function that can update all records at once.
As below
Menuitem.update([{id: 1},{position: 3}], [{id: 2},{position: 3}] ).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'); } });
Any help would be greatly appreciated.
Also a problem opened with SailsJS https://github.com/balderdashy/sails/issues/2404
Andre Frexio
source share