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
1 answer
17 views

How to deal with nested results in sequelize?

I want to read data from two associated tables in not nested format using sequelize. Using this line of code: const operator = await operatorService.findOne({ where: { id: id }, include: { model: ...
Juzioikasztanka's user avatar
0 votes
0 answers
3 views

Sequelize - Testing updating a model with virtual fields

I have the following model: const Invoice = sequelize.define("invoice", { number: { type: DataTypes.STRING, allowNull: false, unique: { msg: &...
Enrique Moreno Tent's user avatar
0 votes
0 answers
6 views

Sequelize Error - belongsTo called with something that's not a subclass of Sequelize.Model

I'm encountering an issue with Sequelize when trying to define a belongsTo association between the Comment and User models. The error message I'm receiving is: comment.belongsTo called with something ...
Eric Risher's user avatar
0 votes
0 answers
12 views

findAll() sequelize returns in unexpected order

I'm trying to list all the data related to a table responsible for saving messages on a chat page using the sequelize ORM, but the attributes are being listed in alphabetical order according to the ...
Lucas_0502's user avatar
0 votes
1 answer
21 views

Creating a new record on an associated Sequelize table needs first letter to be upper case

I'm working on a project using NodeJS, Sequelize (6.35.2) and Postgres (8.11.3) and I'm getting this weird behavior. But first, here are the models... user.js const { Model, DataTypes } = require('...
OmaRPR's user avatar
  • 111
0 votes
1 answer
20 views

Cannot connect to CloudSQL via Cloud SQL Node.js Connector using Sequelize, but able to connect through Postgres

Trying to connect to GCP CloudSQL Postgres databsae externally outside of GCP and am trying to use the Cloud SQL Node.js Connector package. I am using Sequelize as my ORM to connect to my postgres ...
Robert Wells's user avatar
0 votes
0 answers
17 views

How to I supply models in specific order for Sequalize?

As of time of writing, I'm having trouble understanding how my tables are currently loaded into Sequalize instance and how to alter the load order. Asking inorder to get rid of an error ...
Ayrton M.'s user avatar
0 votes
0 answers
9 views

(node:12948) Warning: Accessing non-existent property 'Symbol(Symbol.toStringTag)' of module exports inside circular dependency

Eu estou trabalhando em um projeto e criando uma tela de login com mysql, e sempre tive o costume de separar determinados códigos por arquivo, Exemplo: Models; Arquivo Principal(main.js) e etc, e para ...
Lucas Montel Costa's user avatar
0 votes
0 answers
6 views

Sequelize keeps throwing the error this[#arrayParserLib].parse is not a function

SequelizeDatabaseError: this[#arrayParserLib].parse is not a function at PostgresQuery.formatError (/Users/vizsatiz/Documents/hub/aesy-api/node_modules/@sequelize/core/src/dialects/postgres/query....
vizsatiz's user avatar
  • 1,993
0 votes
1 answer
19 views

Sequelize - Unknown column in 'order clause' when sorting by included model

I have the following Sequelize query: const sites = await Site.findAndCountAll({ order: [[{model: Account, as: 'account'}, 'name', 'DESC']]; limit: limits.limit, offset: limits....
LiteralMetaphore's user avatar
0 votes
0 answers
7 views

Sequelize - Does deleting a table mean only a migration or is it all references to it

I am working on a sequelize controlled app. We decided that one of the tables was no longer needed and we want to delete it. To do this, do I simply run a migration to remove the table and any ...
Joshua Foxworth's user avatar
0 votes
0 answers
6 views

How to properly type Sequelize using Sequelize.define?

My team is currently migrating to Typescript and we're having some trouble migrating our v6 Sequelize code. Unfortunately, we cannot use a class based approach so we're stuck with sequelize.define. ...
sumowrestler's user avatar
0 votes
0 answers
35 views

EagerLoadingError in Sequelize (association between models)

I have an error that I don't understand, I'm trying to make it as simple as possible. A simple findAll with an include. (like in the doc : https://sequelize.org/docs/v6/advanced-association-concepts/...
Fino's user avatar
  • 3
0 votes
1 answer
14 views

Sequelize join multiple table and search

I have multiple table like products, category, subcategory and product images. Product has many product images also i want to add filter on category and subcategory with or condition but i am getting ...
ketan pradhan's user avatar
0 votes
1 answer
14 views

Sequelize-cli db:create Cannot read properties of undefined (reading 'replace') when creating DB

I was using sequelize-cli to create postgresql DB using the command: npx sequelize-cli db:create. My config.js file is const dotenv = require('dotenv') dotenv.config() module.exports = { ...
Foysal Khandakar Joy's user avatar
0 votes
0 answers
14 views

Sequelize - How do I drop a database and restart

I am running an app with the database running locally. There seem to be issues with the database somewhere as cascading deletes are not working. I believe that there may be issues with the database ...
Joshua Foxworth's user avatar
0 votes
0 answers
14 views

Bug when testing the setup of Model and Migration connection

I'm currently doing a backend connection with a db, using node, postgresql and sequelize as orm. I've been getting the same error when I try to make a test using the route and creating a static user, ...
JoJo's user avatar
  • 1
0 votes
0 answers
15 views

None of sequelize hooks are executing in expressJS

I'm using sequelize 6.32.0 along with express 4.18.2 and typescript. Problem is, none of the sequelize hooks are working for me. I've tried adding simple console.log statements but the hooks are not ...
ohnope's user avatar
  • 27
0 votes
1 answer
38 views

Sequelize node, new model instance returns string literal instead of actual value

When I am creating a new instance of model using await Session.create(), its returning the default literal, instead of the generated value. I am getting dataValues: { id: Literal { val: '(UUID())' }, ...
Arsh's user avatar
  • 45
0 votes
0 answers
19 views

Can't fix @BelongToMany() communication problem

Gives errors when trying to run the code. user.ts import { BeforeCreate, BelongsToMany, Column, Model, Table } from 'sequelize-typescript'; import * as bcrypt from 'bcrypt'; import { Task } from './...
Владислав Куликов's user avatar
0 votes
1 answer
42 views

Sequelize Error: .belongsTo called with something that's not a subclass of Sequelize.Model

Hey im trying to design my database architecture so a user can be part of many teams, and a team can have many users. I've created a junction table TeamMembers to achieve this, but im getting an error....
Sam King's user avatar
0 votes
1 answer
24 views

Cannot select multiple tables using sequelize

I was very confused in selecting employee and leave data using the master number contained in both tables. Can someone help me, here is code: karyawan model file: 'use strict'; module.exports = (...
NinjaTea0161's user avatar
0 votes
0 answers
31 views

Sequelize: Dialect needs to be explicitly supplied as of v4.0.0

i'm using nestjs/sequelize/postgres i initiated my db and passed it as provider to my database module,i explicitly supplied dialect and used NODE_ENV= development in my .env file,but i still get the ...
ShayanJZ's user avatar
-1 votes
0 answers
21 views

sequelize migration error because of foreign key

i have created migration file and inside i created two tables but i am having following issue when i try to create a table .. creating two tables inside one migration does it gives error ... Sequelize ...
Sandip rumba Lama's user avatar
0 votes
1 answer
41 views

Why, in Sequelize, locking row causes update to get stuck while in the same transaction?

I'm using node.js as a backend for a booking flight ticket project and i'm also using Sequelize to operate on the DB (PostgreSQL). The DB is online, hosted on Clever Cloud. I've two controllers, named ...
Luca Gaetani's user avatar
0 votes
0 answers
23 views

There is an error when creating a table in the Sequelize migration in Node.js

When I create two tables Products and ProductColor in mysql, and add references for ProductColor, I encounter the error: ERROR: Can't create table etradeshop.productcolors (errno: 150 "Foreign ...
Solider's user avatar
2 votes
1 answer
49 views

Can't connect AWS RDS using sequelize

When I use this code, I can connect successfully to my AWS RDS postgre import pg from "pg"; import dotenv from "dotenv"; dotenv.config(); (async () => { try { const ...
Nghĩa Phạm's user avatar
0 votes
1 answer
20 views

how to filter in sequelize order.getProducts(req.params.productId)

I want to send get request to card like get card/:productId. is it possible to insert parameter for order instance ?? const products = await order.getProducts(req.params.productId); I just got all ...
Mehmet Baki's user avatar
0 votes
0 answers
16 views

How to properly manage the services and interfaces for the same model with Sequelize when I sometimes want to fetch associations and sometimes not?

I'm developing REST APIs with Node.js + TypeScript + Sequelize, and I have a little library system whose sequelize model definitions are like below: export interface Book { id: number; name: ...
Ryan's user avatar
  • 11
1 vote
0 answers
38 views

Sequelize update() with 'returning: true' not finding Types if code is in NPM package

I am trying to get [email protected] to return an updated object (Azure Function v4, Typescript, [email protected], Azure SQL Server) as per update() option returning: true. See the commented out line ...
Aiden Dipple's user avatar
0 votes
1 answer
20 views

insert data into associative table in mysql workbench using node js

i have 2 table: instrument and performance (many to many relationship). I want admin can create a performance which contain many instruments. But i have some error when insert into associative table. ...
Minh Trần's user avatar
0 votes
2 answers
32 views

How to calculate totalPrice? in sequelize?

I have four table Users, Orders, OrderProducts(joın table), Products, I want to calculate totalprice cloumn in Order table, OrderProducts has quantity and productId, product has price column, I want ...
Mehmet Baki's user avatar
1 vote
1 answer
30 views

Sequelize migration is being applied however there is no change to the database

I have a simple migration that renames a column. The migration file looks like this: const tableName= 'aTable'; module.exports = { up: async (queryInterface, Sequelize) => { ...
lordoku's user avatar
  • 1,012
0 votes
0 answers
17 views

Cross-Database Associations in Sequelize ORM

I have two DBs Db1 is 'instance_db' and Db2 is 'system_db'. In 'instance_db' I have models like person and in 'system_db' I have models like gender. I have to join person model with gender model which ...
Learning's user avatar
0 votes
0 answers
24 views

How to count products with sequelize when using include inside an other include

I have 4 tables. when I get my customer info I want to count products which customer ordered. I tried this way but it doesn't work I think the problem is with group And I'm getting this error "...
Sadra Mehriyan's user avatar
0 votes
1 answer
16 views

sequelize how to increment a value from many to many relation

I want to increment or decrement quantity value if it exists in orderproduct join table const product = await Product.findByPk('152b12ac-a59e-44f1-b83f-9770e0b8c01e'); let exits =await order....
Mehmet Baki's user avatar
1 vote
2 answers
48 views

sequelize add method many to many doesnt work

I have Order.belongsToMany(Product, { through: 'OrderProducts'}); Product.belongsToMany(Order, { through: 'OrderProducts' }); I want to add products to my currentorder let newOrder = null ...
Mehmet Baki's user avatar
0 votes
0 answers
24 views

automatically create table on sequelize.js + next.js

I have fullstack nextjs project and for connecting to mysql database I am using sequelize.js. Consider I have a comments table and at first this table does not exist but I want this table to be ...
Ahmad Reza's user avatar
0 votes
1 answer
26 views

Sending both image and data in postman via form-data fields

I'm new in node.js and I am working on a project which is made in node.js and sequelize. How can I send both image and data in postman via body form-data? I have searched on internet for a solution ...
Mohsen's user avatar
  • 280
0 votes
1 answer
28 views

How to do custom order by string using sequelize

How to do custom order by using sequelize I need to sort array of objects retrieved from db as ACTIVE, PENDING, INACTIVE How to do using sequelize Tried sortOrder = [[Sequelize.literal(`CASE WHEN ...
learntocode2468's user avatar
0 votes
0 answers
46 views

How to fix this error, i use Nodejs and ExpressJs TypeError: Class constructor model cannot be invoked without 'new' in

Error TypeError: Class constructor model cannot be invoked without 'new' I can't request an API and there is a response like that, How to fix this error? My PatientPhysiqueModel.Js import Patient from ...
whennnn's user avatar
  • 11
-1 votes
0 answers
27 views

Change the sequelize ENUM roles in Authentication nodejs

I have both controller(authenticateUser.js) and user model, and i want to update the user role to seller if the req.body.seller is true because the default role is user, I visualize different ways to ...
Muhammad Faisal Ramzan's user avatar
0 votes
0 answers
20 views

async await in virutal field in sequelize node.js

Not able to get the s3 signed url for a virtual field in sequelize node.js When trying to fetch file_uri (virtual field) returns empty object {} S3 Signed Url Function exports.getSignedUrl = async (...
Sharath's user avatar
  • 2,358
0 votes
0 answers
12 views

How to disable sequelize cli log - Sequelize CLI [Node: 10.21.0, CLI: 6.0.0, ORM: 6.1.0]

I am using sequelize cli to configure postgresql and run migrations/seeders. There are a couple of logs being printed unnecessarily and might also reveal internals of my service. I would want to ...
Tejas Bramhecha's user avatar
-1 votes
0 answers
38 views

Why object properties are getting undefined?

In my usecase of creating flights, I need to get the total capacity of the airplane whose id is provided by the user.so for that I am retrieving the airplane object from the table with the id ...
Vatsal A Mehta's user avatar
0 votes
0 answers
15 views

belongsToMany relation Sequelize

I have this models class PostFeed extends Model { static init(sequelize) { super.init( { content: Sequelize.STRING, id_autor: Sequelize.INTEGER, id_empresa: ...
Bruna Santos's user avatar
0 votes
0 answers
13 views

belongsToMany relation using Sequilize

I have this models class PostFeed extends Model { static init(sequelize) { super.init( { content: Sequelize.STRING, id_autor: Sequelize.INTEGER, id_empresa: ...
Bruna Santos's user avatar
0 votes
0 answers
25 views

Sequelize 6 + SQL Server bulkCreate with associated data

I have and issue using sequelize 6.35.1 and SQL Server. I'm trying to migrate from a mongodb database to SQL Server relational, so I wrote some scripts. One of them is supposed to create a data ...
Aurélien Vaast's user avatar
0 votes
1 answer
28 views

Closing a connection when using two different connections and the same model files

I'm having a little difficulty with my sequelize setup and looking for some guidance/help. The scenario I'm working with as follows: Electronjs application that has two sequelize connections: sqlite ...
rabrowne's user avatar
0 votes
0 answers
20 views

Why not able to create records in sequelize models?

I am using sequelize models and created City model using the sequelize-cli. The model and table is getting created after applying the migration. I have also created a repository for creating records ...
Vatsal A Mehta's user avatar

1
2 3 4 5
249