i'm going through (excellent) sails.js book, discusses creating user model user.js
in chapter 6 so:
module.exports = { connection: "needaword_postgresql", migrate: 'drop', attributes: { email: { type: 'string', email: "true", unique: 'string' }, username: { type: 'string', unique: 'string' }, encryptedpassword: { type: 'string' }, gravatarurl: { type: 'string' }, deleted: { type: 'boolean' }, admin: { type: 'boolean' }, banned: { type: 'boolean' } }, tojson: function() { var modelattributes = this.toobject(); delete modelattributes.password; delete modelattributes.confirmation; delete modelattributes.encryptedpassword; return modelattributes; } };
using postgres, new record correctly populates boolean fields not submitted login form null, book suggests should case:
but want use mongodb instead of postgresql. had no problem switching adaptor. now, when create new record, appears ignore schema in user.js
, put literal post data db:
i understand mongodb nosql , can take parameters, under impression using schema in users.js
apply post request /user
endpoint (via blueprint routes now) regardless of database sitting @ bottom. need somehow explicitly tie model endpoint nosql databases?
(i've checked records created in postgres , mongodb, , match responses localhost:1337/user posted above)
i understand mongodb nosql
good! in sails sails-mongo waterline module responsible regarding mongodb. think found relevant code: https://github.com/balderdashy/sails-mongo/blob/master/lib/document.js#l95 sails-mongo not care non existent values. if think bad feel free create issue on github page.
a possible workaround might using defaultsto:
banned : { type : "boolean", defaultsto : false }
Comments
Post a Comment