sails.js - How to use bigserial for primary key id with Sails js -
i have following model definition:
module.exports = { attributes: { id: { type: 'bigserial', primarykey: true }, email: { type: 'email', required: true, unique: true } }
when lifed sails, didn't give me warning "bigserial" data type, though not officially documented.
however, on table created on postgresql, column "id" has type "text". how have bigserial primary key?
you can use command in db `alter table your_table add column key_column bigserial primary key;
in sails model can use somethin this:
module.exports = { connection: yourconnection, tablename: yourtablename, attributes: { id: { type: 'integer', autoincrement: true, primarykey: true }, email: { type: 'email', required: true, unique: true } }
note: need set db connection config on config/connections.js
somepostgresqlserver: { adapter: 'sails-postgresql', host: 'your_postgres_server_hostname_or_ip_address', user: 'your_postgres_user', password: 'your_postgres_password', database: 'your_postgres_db' }
and run npm install sails-postgresql
in project folder
Comments
Post a Comment