sails.js - including toMany list of IDS in REST response from sailsjs -


i have sails model ("folders"):

module.exports =    attributes: {     name: type: 'string'     parent: model: 'folder'     folders:        collection: 'folder'       via: 'parent' 

when retrieve via rest api, want response looks like:

[ { name: 'foo', parent: 34, folders: [292, 358] } ] 

however, sails leaves out "folders" attribute.

what simplest way tomany included (this 1 example -- there more tomany's, otoh don't want them included -- should configurable per-relation)?

it seems "tomany" associations suppressed default "tojson" method sails provides.

to override, in object definition, inside of objects, override tojson:

_ = require 'lodash'  attributes: {    ...    tojson: ()->     return _.extend {}, 

this use defaults provided "json.stringify", , "tomany" relationships sent lists of ids (if adapter has returned model).


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -