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
-1 votes
0 answers
10 views

Id is not found when i Trying to delete data using method

3 sequelize models namely account, account type, accountgroup and want to delete all record of account type which are stored on one accountgroup but it showing id not found This is getall data ...
shubham ghule's user avatar
0 votes
0 answers
5 views

Sequelize adds a bunch of spaces at the end of the DataTypes.CHAR

My Store.ts file: import {DataTypes, Model, ModelAttributes} from "sequelize"; export default class Store extends Model { declare id: number declare name: string declare phone: string ...
NotEasy's user avatar
  • 41
0 votes
0 answers
11 views

TypeScript complains when I define a Sequelize model with an id, but don't provide an id when calling Model.create()

I'm using the class style model declaration: export class Supplier extends Model<InferAttributes<Supplier>, InferCreationAttributes<Supplier>> { declare id: number declare ...
Nikolay Dyankov's user avatar
0 votes
0 answers
9 views

NodeJs backend with Sequelize as my ORM not working

I currently have a NodeJS backend and sequelize as my ORM and postgress as my database. I will post below my file structure and can anyone tell me if what im doing is correct or not please. Would ...
kd12345's user avatar
  • 757
-1 votes
0 answers
8 views

createMethod not working in one-Many association in sequelize

const express= require('express') const cors = require('cors') const bodyParser = require('body-parser') const reviewRoute = require('./router/reviewRoute') const sequelize = require('./util/database')...
sean's user avatar
  • 9
-1 votes
0 answers
12 views

Handle replica db failure in sequelize, which is using read replication

I am using sequelize in my nodejs application and with read replica feature we are connecting both db and redirecting our read queries to replica db using this config const sequelize = new DbSequelize(...
Gaurav Aggarwal's user avatar
0 votes
0 answers
10 views

How to determine selection of an instance based on the associated instance in a 1:M relationship?

I have two models Task and TaskMember Task id: Primary key added_by: Foreign key to user title TaskMember id: Primary key task_id: Foreign key to task member_id: Foreign key to user Both these model ...
PaOne's user avatar
  • 3
-1 votes
1 answer
27 views

Wrong pagination in MAX() query of postgres

This is my query to fetch the latest message from each room: SELECT MAX ( "Messages"."id" ) AS messageId, "Rooms"."id" FROM "RoomUsers" ...
dumpAndDie's user avatar
0 votes
0 answers
23 views

MySQL error when inserting data into JSON column ER_INVALID_JSON_CHARSET

Last Saturday I've upgraded our database into MySQL 8 since AWS is deprecating 5.7. Everything seemed to be working at first, but now we are seeing issues in our system. I'm using expressJS & ...
Andrei's user avatar
  • 1,185
0 votes
0 answers
23 views

How to use Sequelize Transaction inside a node-schedule job?

How do I use Sequelize Transaction insde a node-schedule job? For example I have this function here: async doSomething( params ) { // Create > Transaction1 const ...
yeln's user avatar
  • 626
0 votes
0 answers
11 views

Why is sequelize not generating automatically my join table?

I am trying to make a many to many relationship with sequelize, nodejs, and expressjs. I have my Sale.model.js const { Sequelize, DataTypes } = require('sequelize'); const sequelize = require('../...
tukitooo1998's user avatar
1 vote
1 answer
27 views

Postgresql: resolve a one-to-many relationship and delete given tuples, all in one query

I have a table as such: CREATE TABLE users (id, ...) CREATE TABLE groups (id, ...) CREATE TABLE group_roles (group_id REFERENCES pages.id, role, ...) CREATE TABLE user_memberships ( user_id ...
Jeff Hemphill's user avatar
0 votes
2 answers
50 views

I build an API with Sequelize and my controllers don't display foreign key informations with findAndCountAll

I'm a beginner in creating APIs with NodeJS and Sequelize. Before coming here I searched for my problem on several forums/docs but I always get the same result. As you can see in my result, I always ...
gael swinne's user avatar
0 votes
0 answers
11 views

Next.js high connection count with SSG

I have a nextjs site with about 7800 product pages. The site runs completely fine when I have the product pages setup as SSR with getServerSideProps. However, if I switch them to ISR, I quickly run ...
Justin Lok's user avatar
  • 1,232
0 votes
0 answers
48 views

Issue with Sequelize migration - "No database selected" error

Title: Issue with Sequelize migration - "No database selected" error Description: I'm currently facing an issue with Sequelize migrations. When I try to run npx sequelize-cli db:migrate, I ...
tuiqs's user avatar
  • 5
0 votes
0 answers
40 views

InnoDB - errno: 1005, sqlState: 'HY000' sqlMessage: "Can't create table (tableName) (errno: -1)",

I was trying to make club, and students database I am using sequelize, my engine is innoDB and I wrote like this module.exports = (seq, DataTypes) => { const Club = seq.define("clubs",...
Mineppl13's user avatar
0 votes
0 answers
26 views

How can i remove json object from mysql sequalize

I am using Nodejs express and my database is Mysql with sequalize.. I am storing very large json data but my requirement is i want to clear stored json first, then store new json that is coming from ...
eternalyogi's user avatar
0 votes
0 answers
32 views

Sequelize : Count LEFT OUTER JOIN Table Row Not Working

I have searched stackoverflow for the answer to this, none worked, all throws the same error: Unknown column 'contact_label.label_id' in 'field list' for example: https://stackoverflow.com/questions/...
yeln's user avatar
  • 626
0 votes
0 answers
28 views

Sequelize Error: Named bind parameter "$amount" has no value in the given object

This is my sequelize code: const insertQuery = ` INSERT INTO transaction (amount, company_id, user_id, journal_id, type, account_id, plaid_transaction_id) SELECT $amount, $company, $user_id, $...
Zain763's user avatar
  • 77
0 votes
1 answer
29 views

How to get an array of joined table in sequelize in findAll()

const response = await OrderDal.findAll({ where: { buyerId: userId }, attributes: { exclude: ['outcomeId', 'programId'] }, include: [ { model: User, as: 'buyerOrders', ...
Numaira Nawaz's user avatar
0 votes
1 answer
45 views

Electron + Vite + Sequelize

Stack: Electron + vite + vue I have the issue with sequelize framework. My model looks like: Operation.init({ itemId: { type: DataTypes.STRING }, startDate: { type: DataTypes.DATE, }, ...
user3512339's user avatar
0 votes
0 answers
38 views

Sequelize Models, registered, synced, but how to do CRUD-Operations?

i used a course on udemy to make my first steps with sequelize: https://github.com/DavidArmendariz/sequelize-course/tree/master Because I only want to use ES-Modules I had to make a few adjustments. ...
Daniel Hüpenbecker's user avatar
0 votes
0 answers
15 views

count with group and joins in sequelize node.js

Below is mysql query which works select c.name, count(*) as 'count' from product p join product_category pc on pc.product_id = p.id join category c on c.id = pc.category_id where p.user_id = 1 group ...
Sharath's user avatar
  • 2,368
0 votes
1 answer
41 views

Unable to connect to Cloud SQL (PostgreSQL) instance with Sequelize

I am simply not able to establish a connection to my Cloud SQL instance (PostreSQL). For deployment, I have created a cloudbuild.yamlbut no matter what I try, I'm not able to connect. For now, I am ...
Stefan Falk's user avatar
  • 24.5k
0 votes
0 answers
31 views

Sequelize "is not associated" model problem

Got a problem with associations using sequelize. models/Category.js import { sequelize } from '@/utils/server/db' import { Sequelize, Model, DataTypes } from 'sequelize' class Category extends Model {...
TheMoose's user avatar
0 votes
0 answers
12 views

SequelizeJS ordering by nested includes

I try to order my include models but it still not working when I add sub_section model. It works for section model. Working code : sequelize.models.page .findOne({ where: { id }, ...
tonymx227's user avatar
  • 5,381
0 votes
0 answers
13 views

Sequelize query to count total based on foreign key from second table (3 tables)

I have 3 tables. courses, course_sections, and course_videos. courses has a one to many relationship with course_sections which has a one to many relationship with course_videos. I want to return ...
Shawn Trzandel's user avatar
0 votes
1 answer
21 views

Why I cannot select the specific Game object?

I want to increase my game which is select(you can se below), but unfortunately my selection not working it throws an exception. I want to make the following sql query: Select * from Games where ...
Gábor Kiss's user avatar
0 votes
1 answer
60 views

Sequelize transaction include not working when creating objects?

I'm adding objects into a SQL Server database with Sequelize. I perform all operations in one single transaction. When I want to retrieve the inserted objects, the associated models aren't fetched. ...
Michael90's user avatar
  • 367
0 votes
0 answers
14 views

Sequelize association hasOne(one to one relationship) is creating 2 foreign keys in mySql (in expressJs)

I am defining 2 columns us,books with primary key usId and bookId respectively. After that i am using association us.hasOne(books,{foreignKey:'usId'});books.belongsTo(us). These lines are now creating ...
user23336424's user avatar
0 votes
0 answers
26 views

Is it possible to pass an object into model.init in Sequelize?

I'm wondering basically what the title says, since for my nodejs application I need to create multiple tables with the same set of columns, so I'm wondering if I can do something like this: Let's say ...
Dan P's user avatar
  • 31
0 votes
0 answers
17 views

Nodejs Sequelize Require Module with connection parameter

I have 2 database connections, one for read and one for write. I want to keep the read connection as default when a model is loaded. const Sequelize = require("sequelize"); const readDB = ...
jolly's user avatar
  • 3,453
1 vote
1 answer
48 views

Remove sensitive Sequelize error messages in Express.js

I have a bunch of sequelize models defined for my database. We are using Express to create CRUD APIs to handle db operations and the UI will call these APIs for the user interaction. Now my biggest ...
Nimesh's user avatar
  • 31
2 votes
1 answer
68 views

Indexing strategy for filters including a JSONB property

I have a jsonb column created via sequelize migration this way: queryInterface.addColumn('Entities', 'summary', { type: Sequelize.DataTypes.JSONB, }) My Postgres version: PostgreSQL 15.2 (Debian ...
Joe Beuckman's user avatar
  • 2,286
1 vote
1 answer
49 views

Sequelize with sqlite auto increment strange errors. No error but no auto increment when I use AutoIncrement but error when I use autoIncrement

I'm creating a discord bot. With 2 slash commands. One command named /setup for adding the guildId and a adminChannel to the database. And one command named /onduty for adding the user, onduty and ...
GoldODev's user avatar
0 votes
0 answers
28 views

azure-active-directory-service-principal-secret node sequelize migrations

I'm connecting db with service principal by using below method in express using link but while running migrations it will establish connection from db.config file where db.config file contains "...
vijay vijju's user avatar
0 votes
0 answers
18 views

How to add modules using sequelize-typescript & es modules & providing path?

const _sequelize = new Sequelize({ host: dbHost, database: dbName, dialect: "postgres", username: dbUsername, password: dbPassword, logging: false, models:[...
Berk Demiröz's user avatar
0 votes
1 answer
36 views

How to create ES module ('.mjs') migration files through sequelize-cli?

I'm writing PostgreSQL database migrations in my NodeJs project using sequelize-cli and trying to follow ES module syntax in my files. Unfortunately, I can't find how to enable creation and execution ...
Vold's user avatar
  • 33
0 votes
0 answers
10 views

how to find join tables and filter only results where it has all matches in an array?

I have a database that has a demo, allyTeam, and players tables. demo has many allyTeam. allyTeam has many players. Say I want to find all demos where Alice and Bob are both players in the demo. I ...
Joshua Augustinus's user avatar
0 votes
0 answers
28 views

Is sequelize flawed? How to ensure independent DB connections in an Express server?

Ok, this is the situation: I don't think there is a way to ensure independent DB connections for each HTTP request in a Node server that uses the sequelize NPM package. I am currently using Express, ...
José Ramírez's user avatar
0 votes
0 answers
21 views

PassportJS, PassportJWT and Express - 401 Unauthorized

App.ts - This is done initially to setup the strategies. I have bodyParser before them and setup like shown. // for parsing application/x-www-form-urlencoded this.app.use(bodyParser.urlencoded({ ...
smb's user avatar
  • 559
0 votes
0 answers
13 views

_backup table out of sync with main table in Sequelize

In my Node/SQLite/Sequelize project, the database is initialised like this: import db from './db.ts'; import Order from './orders.ts'; import User from './users.ts'; await db.sync({ alter: true, ...
Steve Bennett's user avatar
-1 votes
0 answers
17 views

Sequelize Spatial Query Issue with Variable Coordinates

I'm facing an issue with a Sequelize spatial query where I'm trying to retrieve records within a 5-meter radius based on latitude and longitude. The query works as expected with hardcoded values, but ...
Sonali Khadake's user avatar
0 votes
0 answers
16 views

"TypeError: Cannot read properties of undefined (reading 'create') when using Sequelize's User.create() method"

I'm facing a peculiar issue with my Node.js application using Sequelize. When I run my code locally, everything works smoothly without any errors. However, when I send a POST request using Thunder (a ...
Yacine Ben chikh's user avatar
0 votes
1 answer
21 views

How to get flag in case of existing record in association in Sequelize

I have a model A with a 1:N association to a model B. I want to get all records from A, and true if there exists at least one associated record from B, false otherwise. The associations: ModelA....
Nicolas's user avatar
  • 63
0 votes
0 answers
24 views

Can't access association field. Sequilize + TypeScript. Property '...Info' does not exist on type

I am developing on Node JS + TS + express + sequilize. I am trying to connect device info table to device table. I thing I am doing same as in official documentation: documentation: class User extends ...
user23356564's user avatar
0 votes
0 answers
9 views

Accessing elements inside a returned sequelize object

In my messageReactionAdd.js file I'm trying to just get the value of one of the properties in the returned object from my query. How can I pull the value myDiscordUsername from the returned query ...
Arvo Bowen's user avatar
  • 4,666
0 votes
1 answer
24 views

Unable to create association with Sequelize

I'm using sequelize for my project and trying to create a simple association between two models. User model: const { DataTypes } = require('sequelize'); import db from '../db'; const UserModel = db....
Alin's user avatar
  • 275
0 votes
2 answers
40 views

API with sequelize and Express: verification in controller

I'm building my API for my app web. I'm using Sequelize and Express. I have created models with Sequelize and I'm writing for the moment the different controller and end-point. My question is: Do I ...
CHAUMONT Clément's user avatar
0 votes
0 answers
42 views

Using PostgreSQL with Sequelize and Umzug in ES6+: Seeking Guidance

I'm currently working on a project using PostgreSQL with Sequelize and Umzug in an ES6+ environment. However, I've encountered challenges with setting up the environment as I want to use ES6+. I'm ...
Sourav Dishri's user avatar

1
2 3 4 5
249