I want to use sequelize.js to query a model for records with a contains restraint. How do I do that? This is what I have right now: but I get the following error: How do you use a contains query in sequelize? Answer EDIT In order to make it case insensitive, you could use the LOWER sql function, but previously
Tag: sequelize.js
Sequelize How compare year of a date in query
I’m trying to make this query: How can I perfome this query above in sequelize style? Thanks! Answer You have to use .where here, because the lefthand side of the expression (the key) is an object, so it cannot be used in the regular POJO style as an object key. If you want to combine it with other conditions you
Using loops and promises in transactions in Sequelize
I am currently building a Nodejs, Express, Sequelize (w. PostgreSQL) app, and have run into a few problems with using promises together with transactions and loops. I am trying to figure out how to use a for loops in a transaction. I am trying to loop through a list of members and create a new user in the database for
Sequelize: Cannot set a new unique constraint message
I am trying to setup a validation message for unique constraint violation for the fields username and email. However, whenever an already taken username is entered, it shows the message defined for the email property, but shows the input for the username property and also says that this input is for the username property. How would I fix this? Here
Sequelize – How to search multiple columns?
I have a database of articles with several columns and would like to be able to search both title and description. Currently, I have: How can I also search the description as well? I’ve read through the sequelize documentation, even in the Complex filtering / OR / NOT queries section, but the examples only seem to explain searching in one
Sequelize Where statement with date
I am using Sequelize as my backend ORM. Now I wish to do some WHERE operations on a Date. More specifically, I want to get all data where a date is between now and 7 days ago. The problem is that the documentation does not specify which operations you can do on Datatypes.DATE Can anyone point me in the right
Remove constraints in sequelize migration
I’m adding a unique constraint in a migration via the migrations.changeColumn function. Adding the constraint works, but since you need to provide a “backwards migration“, removing it the same way does not. It doesn’t give any errors when migrating backwards, but again applying the forward migration results in Possibly unhandled SequelizeDatabaseError: relation “myAttribute_unique_idx” already exists. (The used database is postgres)
Heroku + Node: Cannot find module error
My Node app is running fine locally, but has run into an error when deploying to Heroku. The app uses Sequelize in a /models folder, which contains index.js, Company.js and Users.js. Locally, I am able to import the models using the following code in /models/index.js: This works fine, however, when I deploy to Heroku the app crashes with the following