Questions tagged [sequelize.js]

The Sequelize library provides an ORM (Object-Relational-Mapper) for Node.js, written entirely in JavaScript. Provides easy mapping for MySQL, MariaDB, SQLite, PostgreSQL and SQL Server.

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

Sequelise find function not working with postgres datasource

I am trying to do a simple find from postgres table using sequelize find function. But the function is neither returning any result nor the exception. It would be great if anyone can share some ...
Prerna Jain's user avatar
  • 1,240
0 votes
0 answers
12 views

Association with alias "alias" not exist on Model - Sequelize include error

I hope you are fine, I'm getting this error when I try to get a list of models with nested results using the "include" option with my model in Sequelize. The error says that the alias used ...
Manuel Garcia's user avatar
-1 votes
0 answers
20 views

Sequelize not working correct with typescript

So below is the code i have from my JS version of this but i am moving it over to TS and i cant seem to understand how to convert this to work correct as this export does not have a .find() or ....
FearlessNite345's user avatar
2 votes
0 answers
16 views

getting this error after building the ts files yield User.create({ ^ TypeError: Cannot read properties of undefined (reading 'create')

I am getting this error after running npm run build yield User.create({ ^ TypeError: Cannot read properties of undefined (reading 'create') models/index.ts 'use strict'; const fs = require('fs'); ...
neo's user avatar
  • 21
1 vote
1 answer
13 views

Sequelize association arent incialized

hello im tryng to use include on a query on sequelize but it returns that the two tables are not related model atestado it contains atestado data and two FKs one from medicoModel and another one from ...
Ayron Brhenno's user avatar
0 votes
1 answer
17 views

HostNotFoundError error when running 'npm start' on Node.js server - React Project

Description of the problem: I'm working on a React project and when trying to run npm start on the server folder, I get the following error: HostNotFoundError [SequelizeHostNotFoundError]: getaddrinfo ...
Byron Martinez's user avatar
0 votes
0 answers
23 views

Set sequelizerc config.js with values from azure keyvault - node + typescript

Stack of my BE: Nodejs + typescript, sequelize, Azure keyvault has all the secrets for dbConfig. I have "type": "module" in the package.json of my project, hence module.exports is ...
Shrabanee's user avatar
  • 2,706
0 votes
1 answer
18 views

Sequelize (Sqlite) does not recognize the association between the User and Collection Models in Discord bot

When a new user account is created, my discord bot is supposed to create a balance of coins and a collection that stores characters the user purchases with their coins. So the logic is each User has a ...
Austin Lance's user avatar
0 votes
0 answers
25 views

How to seperate schema and table in the raw query string in Sequelize Migration

I'm trying to create a table using Sequelize migrations with a foreign key reference to a table in a seperate schema in my database. The issue appears to be that sequelize builds the query with the ...
David's user avatar
  • 89
1 vote
1 answer
16 views

Sequelize v7 alpha @ decorators not working

While testing sequelize v7 (alpha) I came across several errors while using simple examples straight from their documentation. For example, straight from the documentation import { Sequelize, ...
bricewa's user avatar
  • 53
0 votes
0 answers
21 views

Role.hasMany called with something that's not a subclass of Sequelize.Model

I'm trying to refer a foreign key between 2 models. but I'm getting this error: throw new Error(${this.name}.hasMany called with something that's not a subclass of Sequelize.Model); ^ Error: Role....
trí đức hà's user avatar
0 votes
2 answers
37 views

How to use MOD in Sequelize?

In MySQL, I can do: SELECT * FROM some_table WHERE MOD(attr, 2) = 0; it gives me all rows which attr is even. How can I do it in Sequelize? I didn't find in the docs. Something like: MyModel.findAll({...
mateusmpbr's user avatar
0 votes
0 answers
18 views

Typescript having problems with comparing dates in Sequelize v6

Consider the following piece of code. I thought this was perfectly fine. I think I have wrote something similar in javascript and it works, but typescript doesn't have the required definition it seems ...
maya tan's user avatar
0 votes
1 answer
15 views

Filter create in sequlize used eager loading

Problem Statement I'm working on a project using Sequelize with a PostgreSQL database, and I'm facing an issue with querying data related to products and their variations. I have two tables: Product ...
arvind kumar's user avatar
-1 votes
0 answers
41 views

Cannot read properties of undefined (reading 'define') sequelize error

i have 2 models info and user, and my point was to make one-to-one associations, but i face this problem and have no information to solve it. here is my db_connection.js file: const dotenv = require('...
Chaplinskyi Artyom's user avatar
0 votes
0 answers
15 views

Sequelize & TS: How can I enforce the shape of the data input of a model's create method?

I have the following sample code where I try to create an instance for a defined sequelize model using an interface to template out the body of the model.create call. import { Sequelize, DataTypes } ...
systems_n_systems's user avatar
0 votes
1 answer
21 views

Sequelize + NestJS: full outer join

Is there a way to return data from db with a condition on a nested object and if the nested object is not present, return the parent anyway? I have two models Mission and Request: export class Mission ...
Edoardo Roba's user avatar
0 votes
1 answer
26 views

Have an optional field in Sequelize

I have 2 Oracle databases, one with the User Scheme (id, username, password) and the second one with (id, username, password, email). My Sequelize model look like this : const User = database.define('...
Blazkowicz's user avatar
0 votes
0 answers
8 views

Sequelize bulkCreate behavior when failures occur

What is the actual behavior of bulkCreate in case only one insert fails? The whole process is cancelled, or the remaining lines are inserted? I read on some forums that the behavior would be ...
mpessurno's user avatar
0 votes
1 answer
17 views

How to hide included nested model from query results

I would like to include nested models in the findOptions interface for my Sequelize query so I can set conditions, but I don't want them displayed as result. I know this has been already asked, but ...
Jozef's user avatar
  • 481
0 votes
0 answers
22 views

NestJS / Vitest - Sequelize response id is null

I'm trying to migrate Jest to Vitest with swc on my NestJS project. I have a problem with Sequelize response : I can't access to the property.id directly in my tests, I should set raw: true on the ...
Quentles's user avatar
0 votes
1 answer
19 views

Sequelize code not showing all data in the result, but does show in the sql result

I have this code: const click_tracking = await ClickTrackingModel.findAndCountAll({ include: [ { model: AppModel, attributes: [], ...
trueicecold's user avatar
0 votes
0 answers
19 views

Issue with POST request: Validation Error in Express and Sequelize

I'm encountering an issue while trying to send a POST request to create a task in my Express.js application using Sequelize as the ORM. I've followed the setup and validation rules, but I keep getting ...
Diego's user avatar
  • 1
0 votes
0 answers
4 views

How to declare Postgres functional indexes in Sequelize model definition

We have a Posgres functional index for a table and would like to have this declared in our sequelize table model definition. When declaring the index as per below... indexes: [ { ...
Michael's user avatar
  • 609
1 vote
1 answer
179 views

LOCK defined as ENUM and Interface in sequelize -> types/transaction.d.ts

I am using typescript for nodejs server. I am using sequelize for MySQL database connection. Everything works fine if I run nodemon server.ts. But npx tsc is throwing following error: node_modules/...
Shrabanee's user avatar
  • 2,706
0 votes
0 answers
67 views

Using AND condition with the same column having different values

I want to fetch the "FormResponseQuestions" where both the conditions are satisfied. For example :- Select * from "FormResponseQuestions" as FQ where ( FQ."qId" ...
Perry's user avatar
  • 264
0 votes
1 answer
22 views

Sequelize: adding 'include' to a findOne query is not working

I have a working NodeJS service running locally against a locally installed MySQL DB. All queries in the following app.js file are working fine, until I try to add the include part to the ...
Mor Sagmon's user avatar
0 votes
0 answers
10 views

How to find and count post based on year and month in MySql Sequelize?

This is my MySQL Table. I want to find and count posts that belongs to every month of current year using Sequelize. How to do that MySQL Table
Shabnam Sabah's user avatar
0 votes
0 answers
8 views

How to convert an attribute of Mongoose with Enum values into MySql Sequelize attribute?

I want to convert an attribute which is written in Mongoose into MySQL Sequelize. Please help me out. var UserSchema = new Schema({ status: { type: String, enum: ['full-time', 'remote'], ...
Shabnam Sabah's user avatar
0 votes
0 answers
23 views

CSS properties is not working in html-pdf library

donationReceipt = async (req) => { try { const { id } = req.query; let donationReceipt = await TblmanualDonation.findOne({ where: { id : id }, include: { ...
Lokendra Kumar's user avatar
0 votes
0 answers
20 views

Sequelize keep creates a table that I deleted from DB and models

I'm using Sequelize and Nodejs to manage the MYSQL server. For some reason, Sequelize keeps creating a table that I deleted from DB and models. I guess it's related to cash or .sync(). Any idea why, ...
yoni349's user avatar
  • 107
2 votes
1 answer
26 views

How to allow duplicates on many to many relationship

I would like to allow my users to borrow books. Whenever a user borrows a book const userBook = await UserBook.create({ UserId, BookId, status: 0, }); And when some ...
cezikmertcan's user avatar
0 votes
0 answers
25 views

When trying to use Model.create({}) I get this: TypeError: Cannot convert undefined or null to object

Right now I'm having some trouble trying to post data with Model.create. I'll show the archives first. **Some words are in portuguese usuarios migration: /** @type {import('sequelize-cli').Migration} *...
Khiuta's user avatar
  • 21
-1 votes
0 answers
151 views

Javascript Error Expected a JavaScript module script but the server responded with a MIME type of "text/html". In a vanilla JS project

I have been working on a site that lets users share images and users can sign in with email and password. I have been using firebase for the user accounts so that I don't need to worry about securing ...
CeliacCoding's user avatar
1 vote
1 answer
17 views

graphql single mutation with two authorizations

i have this mutation that updates tasks, but i don't want to allow admins to modify the assigned_to field i want this to be only modifi-able by the super-admin, here's how the code looks currently and ...
Mohhaliim's user avatar
0 votes
0 answers
27 views

Node/Express Async DB Load, how to deal with models

I'm now going to load db credentials asynchronously via Secrets Manager which has caused me to re-think how my server and db are initialized. I've got the db initialize working asynchronously however, ...
jackie's user avatar
  • 624
0 votes
0 answers
26 views

Sequlize with MSSQL bulk insert fails but does not tell at which row or column it failed

I have an application performing bulk insert in a mssql db via Sequlize. The bulk insertion is failing but does not inform about the exact error. I am catching the error and logging it, but it just ...
Sarthak's user avatar
  • 188
0 votes
0 answers
28 views

Node js Multi tenant with MySQL Sequelize ORM

I am trying to build a multi-tenant using nodejs and MySQL, sequelize as ORM. Here I am trying to use separate databases for the tenants. I have save the tenant details in shared database like this. --...
Ramesh S's user avatar
  • 595
0 votes
0 answers
30 views

Timestamp Discrepancy when Retrieving Sequelize PostgreSQL Data in UTC Timezone

I'm currently encountering an issue with my PostgreSQL setup. In my postgresql.conf, I've configured timezone = 'UTC'. I've also used the commands SET TIME ZONE 'UTC'; and SET timezone TO 'UTC'; in my ...
huang7017's user avatar
0 votes
0 answers
23 views

Count rows mismatched while searching included tables

I'm using Sequelize ^6.32.0 version and the dialect is'mssql'. Search Condition is, let contentSearch: ContentSearch = { raw: false, distinct: true, ...
Naganandhini Novastrid's user avatar
0 votes
0 answers
18 views

AccessDeniedError [SequelizeAccessDeniedError]: Login failed for user ''

My node.js server keeps failing the sequelize connection with the following error. AccessDeniedError [SequelizeAccessDeniedError]: Login failed for user 'tester'. at ConnectionManager.connect (C:\...
anon_jj's user avatar
2 votes
0 answers
26 views

Counting multiple associated entries of same model with Sequelize

I have two tables, transaction and account. A transaction has at least one and optional a second associated account trough two diffrent foreign keys. Using Sequelize (6.32.0), how do I count all ...
Daniel's user avatar
  • 21
0 votes
0 answers
11 views

Sequelize not recognizing custom Model function

I am using sequelize for a database of users and I have added a checkPassword function to the User model to compare the inputted password to the hashed password in the database. Sequelize is telling ...
kylemoely's user avatar
0 votes
0 answers
30 views

count for association table using Sequelize with MSSQL

I need to take the count of association table. I use Sequelize with MSSQL. Tried Code [Sequelize.fn("COUNT", Sequelize.col("Members.id")), "usersCount"], Error message {&...
Muthukumar Marichamy's user avatar
0 votes
1 answer
26 views

make graphql mutation return multiple types

i'm working on creating mutations for a project i'm working on but stuck on the resolver returns, i won't to handle the errors while i'm at it as well by sending back messages for notifications to ...
Mohhaliim's user avatar
0 votes
0 answers
31 views

Check Constraint for Composite Value in PostgreSQL Column

I have a scenario involving two tables in my project: "industries" and "sub_industries." In the "sub_industries" table, there's a column named "piped_name" ...
swabhav tech's user avatar
-1 votes
0 answers
12 views

How to write query without table name but with subquery in Sequelize Nodejs Postgres

SELECT * FROM(SELECT SUM("clicks") AS "clicks",SUM("views") AS "views",SUM("spend") AS "spend",(CASE WHEN SUM(CLICKS) > 0 THEN SUM(...
Ajay Malik's user avatar
0 votes
1 answer
54 views

Nest.js Sequelize transaction commitment issue

I am facing quite interesting problem that I cannot solve. Here is the issue. I have my Nest.js project and I am using Sequelize in order to communicate with the database. At some point I decided that ...
dokichan's user avatar
  • 867
0 votes
0 answers
13 views

Sequelize mysql adding pagination makes model not recognize associated models

I have 2 tables: InvoiceItems and Products and my api has an endpoint to retrieve the most popular products (by most sales) so I join Invoice to products, add a new column which is the sum of ...
Abdullah Baraka's user avatar
0 votes
0 answers
10 views

Eager loading attributes from model associated with another associated model in sequelize

I couldn´t think of a way to ask this, but I have the following models: Coffee, CoffeeGroup and Discounts Coffee is n to n with CoffeeGroup, CoffeeGroup is n to 1 with Discounts How can I do eager ...
Diego Rosselot's user avatar

1
2 3 4 5
247