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-postgresqlin project folder


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -