javascript - Sails.js store a primary keys in postresql -


i trying add setup postgresql database while using sails.js framework.

however, overtime trying save model values in database, i've got following error : error: null value in column "id" violates not-null constraint. there way store id automatically created waterline in postgresql database ?

/models/user.js

module.exports = {   connection: 'postgresqlserver',   schema: true,    attributes: {      id: {       type: 'integer',       primarykey: true     },      name: {       type: 'string',       required: true     }   } }; 

/config/connection.js

module.exports.connections = {   postgresqlserver: {     adapter: 'sails-postgresql',     host: 'localhost',     user: 'root',     password: '',     database: 'myprojectdb',     socketpath: '/library/application support/postgres/var-9.5',      schema: true   } }; 

config/models.js

module.exports.models = {   connection: 'sails-postgresql',   migrate: 'alter' }; 

you should set autoincrement: true id attribute.

btw: waterline automatically add id every model. can disable autopk: false if want.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -