Tuesday, 15 February 2011

node.js - Controller-based Associations/Relations in SailsJS -



node.js - Controller-based Associations/Relations in SailsJS -

say have shoppingcart model one-to-many relation item model (i.e. shopping cart can total of different items).

i can create new shopping cart so:

post /api/shoppingcart

what i'd create restful api item can added (or updated) shopping cart this:

post /api/shoppingcart/:shoppingcartid/item set /api/shoppingcart/:shoppingcartid/item/:itemid

from research i've done far doesn't seem built-in sailsjs. i'd prefer remain away manually setting these routes. there way can automate route shoppingcartcontroller?

never mind, found out sails long have config rest alternative enabled.

it works get, post, , delete methods.

[parentmodel]/:parentid/[childmodel]/:id?

check source: https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/index.js#l319

node.js rest sails.js

No comments:

Post a Comment