I want to insert an array of strings in one column of a postgresql table using waterline ORM of sailsjs.
I have tried making the model Users.js like this :
interest:{
type: 'string',
required: false,
columnType: 'array'
}
The insert query goes like this:
Users.create({ interest : ['programming'] });
The datatype in postgre table for interest column is character varying[].
When i try to perform an insert using this setup, it throws an error:
Specified value (a array: [ 'programming' ]) doesn't match the expected type: 'string'
how can I insert an array in the postgresql table, how should the model look like?
Any help would be appreciated, thanks!
Users.create({interest : JSON.stringify(['programming'])})malformed array literalUsers.create({interest : JSON.stringify(['programming']).replace(/\[/g, '{').replace(/]/g, '}')}). Very ugly though :)interest: { type: 'json', required: false, columnType: 'array' }and just pass likeUsers.create({ interest : ['programming'] });