Skip to content

Tag: javascript

How to use group by in sql? (I need sequelize)

I have But it fails with this error: Works fine without GROUP BY Answer The GROUP BY statement groups rows that have the same values into summary rows, in your case, it is the country_code. It is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more c…

strapi with mysql running simple raw sql

Need to run this query in my test and unable to find the right syntax. This is no postgresql and mysql does not like hyphens in table names. Please suggest. Answer Simply don’t use not allowed characters, it makes the life much more easy. The backticks around the String, where implemented, so that theus…

Get List of Users for a Specific Local Time

In my database, I have a list of users with the user ids and their UTC offset in minutes. It’s in a PostgreSQL database which I access through sequelize in my node application. For example: I want to create a query that, when run, gets me a list of users that have passed 12pm noon their local time. For …

Converting a SQL query to SEQUELIZE

I am trying to wrap my head around creating this sequelize query. I have been able to create 2 separate queries where the ‘order by filter’ works and ‘aliases’ work, but not combined. This is what i currenty have in sequelize Answer You just need to use fn twice: in order and in attrib…

many to many relationship knex js

I am trying to fetch data from the database in this way: I want all the templates and those templates have an array of categories in it so the methode I am currently using currently I am doing this but the object doesn’t seem to alter. Answer You are not waiting for the promises to resolve. You should d…