node.js - Disable automatic population of models in sails v1.0 -


i using sailsjs v1.0.0-36. want disable model population.

so when send request http://my-app/pets:

[   {     id: 1,     breed: 'wolves',     type: 'direwolf',     name: 'ghost',     owner: 1, //user id   },    {     id: 2,     breed: 'wolves',     type: 'direwolf',     name: 'summer',     owner: 1, //user id   }, ] 

and when send request http://my-app/users:

[   {      id: 1      firstname: 'john',      lastname: 'snow',      pets: [ //array of pets id        1,        2,      ]   } ] 

where user model defined as

// myapp/api/models/user.js  // user may have many pets  module.exports = {    attributes: {      firstname: {        type: 'string'      },      lastname: {        type: 'string'      },        // add reference pets      pets: {        collection: 'pet',        via: 'owner'      }    }  };

and pet model defined as

// myapp/api/models/pet.js  // pet may belong single user  module.exports = {    attributes: {      breed: {        type: 'string'      },      type: {        type: 'string'      },      name: {        type: 'string'      },        // add reference user      owner: {        model: 'user'      }    }  };

in sails v0.12.0 can in /config/blueprints.js setting

populate = false 

but deprecated in sails v1.0, following this docs can achieve overriding parseblueprintoptions, , this default implementation of function.

how can override achieve required results?

according commit sailjs 1.0 started support option again.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -