【发布时间】:2016-02-06 14:24:20
【问题描述】:
我正在尝试在使用sails.js 框架时添加设置postgresql 数据库。
但是,当我试图在我的数据库中保存一些模型值时,我得到了以下错误:error: null value in column "id" violates not-null constraint。有没有办法将水线自动创建的id存储在postgresql数据库中?
/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'
};
【问题讨论】:
标签: javascript postgresql sails.js waterline