I’m new to Sequelize and am having trouble getting timestamp data from a Postgres database. Everything I have tried so far returns null for all timestamp fields. Below are the Postgres definitions for the columns in question: These are all the different ways I’ve attempted to define the relevant portion of the model in Node.js (tried the same things for
Tag: sequelize.js
Sequelize logging questions marks instead of values after migrating to V5
After migrating to v5 from v4, Sequelize logs question marks on the console instead of the values of the SQL queries. For instance, this is what is shown on the console: This is my Sequelize instance: Whether before, on version 4, the values were being displayed correctly. What I am expecting to be logged is somethings like: Answer You will
Compare Timestamp with date in sequelize query
I have createdAt column which stores value as “2018-11-07 15:03:16.532+00”. I want to write query like select * from table_name where createdAt = input_date, where myinput_date is only date value like 2018-11-07. How do i write this query using Sequelize? Answer try using the sequelize.fn() argument, for example like this, try adjusting it. Ex:
sequelize compare date with date-timestamp
my simple use case is I pass a date and try to compare that with the default createdAt column. and my date is a string like this date = ‘2018-12-12’ The problem here is sequlize not compare only the date. But it does add time 00:00:00 to my date and then compare. So the query sequlize generate is like this.
How to set extra attributes of through model on creation in SequelizeJS?
My models: My associations: My problem: How can I create a Recipe with some Ingredients and the quantities attached to them? I tried: Records are created for Recipe, Ingredient and the Recipe_Ingredient. The only problem is that the value of the quantity is not collected from the data source. Answer It was not possible to do this in the past,
Sequelize relationship query returns duplicate data
I’m querying customer orders for a specified customer using Sequelize relationships. index.js service.js results expected Answer All you need is to remove raw: true, from query , as it will return plain/flat object , and that will convert your object as it looks now. Note : You should put the where condition in upper level as per your logic
Sequelize.js – “is not associated to”
I have some issue with getting full data from db. That are my models: User Role I want to get object of one specific user including all role content. Somethink like So I’m using: but I get in the result err.message: “role is not associated to user” And the simple question – what’s wrong ? 🙂 *to handle models I’m
error on sequelize raw query: query is not a function
I’m trying to use raw queries from sequelize in an express app. My folder structure is: I want to use sequelize which I already define in /models/index.js from a controller. This is /models/index.js: I want to use a raw query in my price controller: But I’m getting this error message: How can I fix this? Answer The Sequelize library is
sequelize include returns only one result
I have a Users table and a Groups table, when I retrieve a single user, I want to get a list of all the groups that user belongs to. I created a joins table named GroupUsers and it has userId and groupId on it, this is how I know that a user belongs to a group. Now, when I try
NodeJS doesn’t like passport + sequelize logins
I’m going crazy with nodejs. I’m trying to realize the backend for a simple user management webapp powered by NodeJS, using Passport-Local and Sequelize libraries. Right now I just designed the user model. The main problem I have is that the signup process gives me an error: it looks like that I’m working on an undefined object. Could please someone