javascript - Sails.js - how to save only model's fields into database? -
let's have model defined:
module.exports = { attributes: { username: { type: 'string', required: true, unique: true } } }
then create object save database:
var obj = { username: 'blabla', score: 100, whatever: 'else' } model.create(obj).then(...);
the additional fields persisted database. question - how save fields defined in model? in case - username, when trying save 3 fields.
i used like:
model.create({username: obj.username}).then(...);
but wonder if there way without having map every field explicitly, because it's not easy maintain, , model kinda loses purpose.
try this:
schema: true
link doc:
http://sailsjs.org/documentation/concepts/models-and-orm/model-settings#?schema
Comments
Post a Comment