All Questions
Tagged with node.js sequelize.js
8,511
questions
1
vote
1
answer
32
views
Separating routes into different modules
I've been putting my all routes into one server.js file, after a while i realised there is about 1000 lines in one file and it is hard to manage it. The question is there a simple way to seperate ...
0
votes
0
answers
12
views
Connection refused when using Sequelize with MySQL running on Docker [duplicate]
I am building a dockerized API with MYSQL. I have already set up a network between the two services but Sequelize is returning a connection refused error.
Here is my Dockerfile for the API
FROM node:...
0
votes
0
answers
21
views
Good way to save and load datas many to many "complex" association with Sequelize
I'm trying to insert and load my data in a belongsToMany - belongsToMany association.
I'm having trouble with the recipe and ingredient association.
Here is my database diagram:
Here is my models:
...
0
votes
0
answers
34
views
How can I use the concat operator (||) in Sequelize for ilike comparison?
I'm working on an express.js project, using Sequelize on a postgres database, and we have the following query:
SELECT *
FROM Client
WHERE first_name || ' ' || last_name ILIKE '%search term%'
I'm ...
-3
votes
0
answers
26
views
Does sequelize sanitize enough inputs? [closed]
I was wondering since I use Sequelize for all my queries. Should I even bother sanitizing inputs since Sequelize handles that?
If yes, In what specific I do need to sanitize the inputs? And since I'm ...
-1
votes
1
answer
42
views
Relative path issue when executing ES module file with node
I need little help with building custome npm command to run ES module file, I am using this file to seed my database.
i am using sequelize in a Node api (not using sequelize CLI or migrations) i want ...
0
votes
0
answers
11
views
SequelizeConnectionAcquireTimeoutError: Best Practices for Using Sequelize ORM in Node.js Application
I’m using Sequelize ORM in my Node.js application, and I’m encountering an issue where I sometimes get a SequelizeConnectionAcquireTimeoutError. I’d like to get feedback on whether my approach is ...
0
votes
0
answers
34
views
Socket.io events in React.js and Node.js not being triggered
I'm building a chat application in React js and Node js. The events that I have written in React.js and Node.js do not seem to be triggered. I can login and see data in both the browser and the ...
0
votes
1
answer
43
views
Database migration tool for sequelize
I have some experience with database migration in Python, I used Alembic for managing migrations.
On the node.js side we have sequelize which I found it's a nice ORM (good features, etc...), however ...
0
votes
0
answers
18
views
Sequelize slugify is not updating slug when source field is changed
I'm building web app with node js + express + sequelize backend. I created rest-api with 3 collections: goals, cashflows, accounts. For each collection there are CRUD operations available. When I send ...
0
votes
0
answers
36
views
Sequalize to write raw sql join query
I have this query in sql,
const query = `
SELECT prdtl.pono, prdtl.desgcode, d.descr, g.grn_dt,
IFNULL(g.grnQty, 0) AS grnQty,
IFNULL(gd.gdnQty, 0) AS gdnQty
...
0
votes
1
answer
37
views
Sequelize doesn't works well with tests
I have some tests and, if I run only that test individually, it works normally, but if I run all the tests, it keeps printing No description found for "Users" table. Check the table name and ...
0
votes
0
answers
19
views
Most efficient way to do a "bulk update" in Sequelize
We have an aws serverless node project, and we're using Sequelize to access our Postgres database.
There's an endpoint that updates several rows, each with it's own data (right now is limited to 50 ...
0
votes
0
answers
34
views
sequelize-auto conf overwritten
I'm trying to use sequelize-auto to create models for my postgres db. I'm following the docs and have this config.js:
const path = require('path');
const output = path.join(__dirname, "./models2&...
0
votes
0
answers
20
views
How to filter entity based on non-assosiated entity in sequelize
I can't filter Kase based on non-assosiated KaseColorLocation inStock property.
Kase entity belongs to many Color through KaseColor
Color entity belongs to many Kase through KaseColor
...
0
votes
0
answers
34
views
Initializing models using initModels function from autogenerated models using sequelize-auto
It's the first time I use sequelize-auto with Typescript and I facing a bit of a problem. I am using sequelize-auto with the following flags
-l ts -o my/folder/path/ --dialect postgres --cm c (with ...
-1
votes
0
answers
24
views
Retrieving Hierarchical Parent-Child Relationships in Sequelize
I want to retrieve a list of all parent companies for a particular company in Sequelize.
Let me give you a scenario to help illustrate what I need:
Company1 is a parent of Company2
Company1 is a ...
-2
votes
0
answers
25
views
Sequelize + Node.js + MySQL API not working after building with Webpack
I’m developing an API using Node.js, Sequelize, and MySQL. The application works fine during development, but when I build the application using Webpack, the API fails to work as expected. I’m not ...
1
vote
0
answers
15
views
How can i implement sequlize inner join
I'm trying to implement an inner join to join my post and categories table, I have tried to console log the result for the listOfCategories and it just shows an empty array. The purpose of the ...
0
votes
0
answers
15
views
Issue Using sequelize.col with findAndCountAll and include in Sequelize with Join Table
Description:
I'm encountering an issue in a Sequelize project when trying to use sequelize.col() to select fields from associated models. The setup involves two main models, Student and User, where ...
0
votes
1
answer
28
views
Sequelize-typescript query runs infinite when using $get with eager loading
I have tried using eager loading in combination with the $get method on a sequelize object:
await user?.$get("following", {
order: [["name", "ASC"]],
limit: ...
0
votes
1
answer
94
views
Best alternatives for a fast search on a big table on a Postgres database?
We have an Express API that connects to a Postgres database using Sequelize.
One of our endpoints returns a list of sales, which accepts different query parameters like page, column order, filters, ...
0
votes
0
answers
23
views
Optimizing Sequelize Synchronization Time with PostgreSQL in NestJS
I'm working on a project using NestJS and Sequelize with a PostgreSQL database. My setup includes around 85 tables, and I've noticed that setting synchronize: true in Sequelize takes about 45 minutes ...
0
votes
1
answer
46
views
how to properly reserve/lock a seat in a booking application
I am building a booking system for clients who want users to book rooms, food, travel, and events. Since there are a limited number of rooms and seats in any event, how do I handle the logic of ...
0
votes
0
answers
23
views
Sequelize Eager Loading Causing Connection / Pool Issues
I recently refactored code for getting posts from a Postgres database from this:
const getPostByPk = async (token, post_id) => {
const requestor_id = await verifyToken(token)
const post = ...
0
votes
0
answers
34
views
nodejs sequelize node beforeConnect hook not working
I am trying to retrieve creds and configure in this 2 ways but its not working.
Now getting any logs from this when I run the lambda!
import * as seq from 'sequelize';
import { retriveCredentials } ...
0
votes
1
answer
35
views
ORM Sequelize model.upsert() is not a function
Version sequelize 6.37.3
I try to upsert() myModel but the mehtod returns:
TypeError: model.upsert is not a function
my_model.controller.ts
...
class MyModelController {
private model: any;
....
1
vote
1
answer
27
views
How can we add String Validation Like Enum In Nodejs and Sequelize
type: {
type: DataTypes.STRING,
defaultValue: "Normal"
}
In this type I want to add validation only the type can be "Normal" or "Installment"
I don't ...
0
votes
0
answers
31
views
Sequelize - PostgreSQL timezone won't change
I can't use anything else but UTC when reading a Date datatype.
Here's my object to be added to PostgreSQL db:
{
"word": "test",
"wordLanguage": "eng",
...
0
votes
1
answer
40
views
How to get Sequelize to recognize by primary key with MySQL database data set and fix bulkCreate() issue?
So I have a database where I am trying to establish a one-to-many relationship between Supplier and TreeSeed, whereby one Supplier can sell many TreeSeed. I have looked at the sequelize documentation ...
0
votes
1
answer
59
views
How to get Sequelize to recognize my custom foreign key and primary keys in a one-to-many relationship in MySQL during bulkcreate insert?
I am building a plant/arboretum style application in JavaScript. I am trying to create a one-to-many relationship between Supplier model and TreeSeed model. Meaning that one supplier can sell multiple ...
0
votes
0
answers
51
views
How to query two Sequelize models through a junction table? Sequelize throwing error on 'through: model'
I am writing a webapp for practice. I have several sequelize models, and querying the db through them so far has been no issue. However, when I tried to use a junction table to return what would be a ...
0
votes
1
answer
33
views
Sequelize code first with mysql cannot generate database
I am facing an issue related to sequelize when generating the database by commandline
npx sequelize-cli db:migrate
The firsting I installing my sql and using MySQL Workbench to connect it -> ...
0
votes
0
answers
54
views
Setting up SQL Server 2012 (v11.0.0) in Node.JS v20.15.0 as Backend API or Data Access Layer Structure
I need to set add-ons on my Flutter project, this is a Backend API using Node.JS which will serve as a middleman API for my Flutter project to retrieve and manage data from database in any platform (e....
0
votes
1
answer
88
views
How to connect Sequelize to Google Cloud SQL database when I have deployed my Node.JS backend api?
I have a Node.js + Express backend API, and I use Sequelize ORM to query my database. My database runs on google cloud SQL and I use the MySQL dialect.
So here is my index.js now where I initialize ...
0
votes
1
answer
36
views
State object is not updating, instead it is showing the default in the database
i'm new to react and I'm trying to update the CategoryId in the state object. In the handleCategoriesChange method, I have attempted to update the state with the option selected from the dropdown with ...
0
votes
1
answer
87
views
Sequelize is not returning all rows for given query
I've got the following sequelize models:
import { DataTypes, Model } from 'sequelize';
class A extends Model{}
A.init {
name: DataTypes.STRING,
start_date: DataTypes.DATE,
end_date: DataTypes....
0
votes
0
answers
33
views
How to make pagination for two lists?
I’m trying to make pagination for two lists.
One list is showing top50 users (who like passed a line) (like ranking), it fetches data from backend, which just gives ranking <= 50, and gives it ...
0
votes
0
answers
27
views
Sequelize in Docker Container Fails to Connect to PostgreSQL Database - ECONNREFUSED Error
I’m facing an issue where my user-service Docker container fails to connect to my PostgreSQL database container using Sequelize. I keep getting the ECONNREFUSED error, and I’ve tried multiple steps to ...
0
votes
0
answers
32
views
SequelizeConnectionError: role "node" does not exist
I have integrated sequlize into my NextJS project. Also, write the migration script for the schemas to be created into PostgreSQL. But, at the time of POST api call I am receiving the error saying: &...
1
vote
1
answer
26
views
Sequelize Postgres - Multiple Interdependent Queries As One
Is is possible to call two queries that run as if they are a single query. Ie. Both queries need to be successful or both fail. I note that the two queries are completely independent, just have a ...
0
votes
1
answer
49
views
Node.js Sequelize : ReferenceError: model is not defined, when using Through association
I need to create a many to many association in sequelize.
I am having this error :
ReferenceError: alertSMSRule is not defined
Here is the code concerning the error :
file alertSMSrule.model.js :
...
0
votes
0
answers
11
views
Sequelize association loading error in aws serverless environment
I have problems loading the associations on serverless environment. I have defined all my sequelize associations in one single file and I load that file at the time of database connection. Now, ...
0
votes
0
answers
35
views
How can I relate models with sequelize in express
I am not being able to make an association between my models, I am using postman to consult a specific provider, for example: Get in http://localhost:3000/api/proveedores/1
My relationship is one to ...
0
votes
1
answer
77
views
How to get list of column names from a query that won't return any rows
I am using MySQL, ExpressJS, and Sequelize to build a function that returns a list of columns from a given SQL query. The function should work even if the query returns no rows.
Here is the current ...
0
votes
1
answer
37
views
ERROR : Sequelize model foreign keys not defined correctly
I have 2 table schemas Customer and Cart
Customer.js
module.exports = (sequelize, DataTypes) => {
const Customer = sequelize.define("custom", {
id: {
type: ...
0
votes
0
answers
28
views
How to establish a one-to-many relationship using sequelize in Nodejs?
I have a model called users.model.js
const postsModel = require("../Posts/posts.model");
const User = sequelize.define(
'User',
{
id: {
type: DataTypes.UUID,
...
0
votes
1
answer
30
views
Sequelize relation errors: Cannot convert undefined or null to object
I am developing a webapp and using Sequelize to manage my database (Postgres).
The User is always found and returns correctly, however finding the Credentials spits out:
TypeError: Cannot convert ...
0
votes
1
answer
99
views
Multiple tenancy with nodejs, sequelize, postgresql
I am currently working on a multi-tenancy project. Our team has decided that each tenant will have its own database, and the structure of the tables in each database will be the same across all ...
0
votes
1
answer
23
views
How do I search an entry in database by the same search phrase for two separate models with reference in sequelize?
I'm trying to make a search in a database for invoices. In the server request handler I have only one thing: searchPhrase. So I have to search invoice by serial number of the invoice, and also by ...