You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Possibility of having an ARRAY datatype with CITEXT fields #9116
I am trying to add a custom datatype for CITEXT as part of an ARRAY. I search the database with case insensitive because I don't control the search terms. Is this possible to do with sequelize?
I tried this:
exportdefault(sequelize,DataTypes)=>{classCITEXTextendsDataTypes.TEXT{constructor(){super()this.key='CITEXT'}}constModel=sequelize.define('artist',{id: {allowNull: false,autoIncrement: true,primaryKey: true,type: DataTypes.INTEGER},slug: {allowNull: false,type: 'CITEXT'// <-- here I use a custom class, this works},names: {allowNull: false,type: DataTypes.ARRAY(CITEXT)// <-- but this does not work}});returnModel;};
What do you expect to happen?
That I could access the ARRAY in sequelize like a normal JS array.
What is actually happening?
This is what I got in the console (which looks correct)
CREATETABLEIF NOT EXISTS "artists" ("id"SERIAL, "slug" CITEXT NOT NULL, "names" CITEXT[] NOT NULL, "createdAt"TIMESTAMP WITH TIME ZONENOT NULL, "updatedAt"TIMESTAMP WITH TIME ZONENOT NULL, PRIMARY KEY ("id"));
Activity
adriaandotcom commentedon Oct 18, 2018
Nice, thanks 🙏
hyber1z0r commentedon Feb 2, 2019
Is it not possible to somehow combine
$containsandsequelize.fn('lower')to achieve this instead?adriaandotcom commentedon Feb 2, 2019
Could be but I don't use Sequelize anymore.