12,477 questions
1
vote
1
answer
35
views
PostgreSQL 63-Character Limit Issue in Sequelize with Multiple Includes
I’m currently working on a project where we are using PostgreSQL with Sequelize to perform complex queries involving multiple nested include relationships. However, we’ve encountered an issue related ...
0
votes
0
answers
9
views
Sequelize sync still running the alter queries even when alter is false
await sequelize.sync({ alter: false, force: false });
My expectation and also as per the sequelize documentation this will only create the new tables if not present, it will not run any alter query.
...
1
vote
1
answer
34
views
NodeJS Sequelize Raw Query Not Returning All 2 Rows
I have 2 rows in the database table moneys.
Using Sequelize, I want to select all rows from the table.
The following raw query in DBeaver MySQL client returns all the results. So, that works as it ...
0
votes
0
answers
16
views
How to properly configure @adminjs/upload to store image files and hide the text input for the file path?
Product Model
import { DataTypes } from "sequelize";
import sequelize from "../util/database.js";
const Product = sequelize.define("product", {
id: {
type: ...
0
votes
0
answers
47
views
How to set all field names to lowercase by default
When querying Postgres, field names are case-insensitive:
select id from contact;
and
select Id from contact;
will both work.
But, when using sequelize (v6), the attribute in my model definition must ...
0
votes
1
answer
29
views
Using import vs require with Node and Sequelize
I'm using type module/import syntax for the rest of my project, but the Sequelize CLI generates files with require syntax. How should I handle this? I'm already having trouble with not being able to ...
0
votes
1
answer
47
views
Sequelize.js with sequelize-typescript started emitting warnings
I've been using Sequelize (6.37.X) on a small side-project for a while. Just a day or so ago, I started having failures in my unit tests, and I'm seeing a lot of this warning on the console:
(...
0
votes
0
answers
49
views
SequelizeEagerLoadingError: ModelA is not associated to ModelB (intermittent in multi-schema setup)
I'm using Sequelize v6.37.5 with PostgreSQL in a multi-tenant architecture, where each tenant has its own schema. Models are defined once globally, and we use .schema(schemaName) to access tenant-...
-1
votes
0
answers
21
views
How to create config file in express to create database on first run?
I was working in a student management project in express with typescript, sequalize ORM in postgres. when running in another system, at first need to create a db manually in postgres then update env. ...
0
votes
0
answers
40
views
Sequelize V7 BelongsToMany Association Adder return is not a function
I make an association BelongsToMany, Chapter as many Chapter with sequelize V7
But when I create a Association Adder I have an error:
TypeError: chapter.addChapter is not a function
This is my model ...
1
vote
0
answers
31
views
mysql2 ETIMEDOUT error with rate-limiter-flexible, but Sequelize connects fine
I'm working on a Node.js backend project and have run into a strange issue involving MySQL connections. Here's the situation:
I am using a MySQL database hosted on Digital Ocean (Managed MySQL ...
0
votes
0
answers
15
views
Typescript Sequelize v6 nested create with associations
Relevant packages:
"sequelize": "^6.37.6"
"sequelize-typescript": "^2.1.6"
I am using sequelize and typescript in a project. I am receiving an error when ...
0
votes
1
answer
43
views
GraphQL not accepting login credentials
So I'm trying to create a user for my task management app, I'm using Express.js, Sequelize ORM for PostGres and Apollo/Server for graphql.
Creating a user works fine, but when I try to login using ...
0
votes
0
answers
20
views
using the sequelize findOrCreate with axios
I am trying to have the sequelize function findOrCreate in combo with axios.
I have a couple of routes setup like:
router.get("/byId/:id", async (req, res) => {
const id = req.params....
0
votes
0
answers
24
views
Sequelize findOrCreate() creates duplicate Terms and Listings
Consider the following models and the following post method:
router.post("/", async (req, res, next) => {
const {
address: addressData,
building: buildingData,
items: ...
0
votes
0
answers
34
views
Data Leakage issue when caching multiple sequelize instance
When I cache multiple Sequelize instances while sharing the same models (entities), the last cached instance in memory overrides the Sequelize instance of the models from the previous cache.
for ...
0
votes
0
answers
11
views
Sequelize CLI access from one model to another
I use sequelize-cli migration scripts to create models
I have created models 'user' and 'user-role'
I want to access to model user_role from the file user
This how my directory structure looks like:
[...
1
vote
1
answer
25
views
Netlify app can't login to Express app only on mobile
I have a Vue 3 app hosted on Netlify, and the backend is hosted on Heroku. The login is a simple /login endpoint made with Express and Sequelize. It works well on desktop, but when I try to log in on ...
0
votes
0
answers
25
views
Sequelize Snowflake (v7 alpha) TypeError when syncing a model
I'm getting a Type error when trying to sync a model with @sequelize/snowflake ( "@sequelize/core": "^7.0.0-alpha.42", "@sequelize/snowflake": "^7.0.0-alpha.45")...
0
votes
0
answers
16
views
sequelize-typescript validation
When adding a sequelize-typescript's decorator to the model field, which should check that the field is not empty, validation does not work and allows you to create a record without passing this field....
0
votes
2
answers
36
views
Function count associated entries with Sequelize return 1 instead 0
I try count foreign table rows with Sequelize
this.publicationModel.findAll({
attributes: {
include: [
[Sequelize.cast(Sequelize.fn('COUNT', 'comments.id'), 'int' ), '...
0
votes
1
answer
34
views
How to push data in an array of JSONB column using sequelize
I have a table named Expenses and the table has a column named expenseEditHistory. The column is of JSONB type. I am using sequelize to manage the database (postgres).
Structure for expenseEditHistory ...
0
votes
2
answers
76
views
SequelizeModule — autoLoadModels / [Nest] ERROR SequelizeModule Unable to connect to the database. Retrying
I'm learning Nest.js, I'm trying to connect via SequelizeModule to my local postgres database, but I keep getting this error
Error when starting start:dev
[20:41:14] Starting compilation in watch mode....
0
votes
1
answer
43
views
Sequelize Model Not Creating Table in MySQL Database (TypeError: Cannot read properties of undefined (reading 'define'))
I’m working on a Node.js project using Sequelize with MySQL. The database connection is established successfully, and sequelize.sync({ alter: true }) runs without errors, but my users table is not ...
0
votes
0
answers
24
views
Sequelize query builder injection safety
With sequelize query builder, I am doing
findOne({where: {foo: myStringValue}})
Is there a chance of injection if myStringValue is not a string as I expected?
It seems like myStringValue could (...
0
votes
0
answers
71
views
How to resolve SSL Required error in Sequelize
When I host my server, I get SSL/TLS Required error, the error is as follows Unable to connect to the database: ConnectionError [SequelizeConntectionError]: SSL/TSL required. I have passed SSL=true as ...
0
votes
1
answer
55
views
Sync Sequelize model with database
I am trying to sync a Sequelize model with my database, but I can't get over this error.
Using Sequelize as my ORM, database is Oracle express:21.3.0-xe
This is the error:
Executing (default): ...
0
votes
0
answers
34
views
Sequelize.Model.create success but never create row in db
Postgres, Sequelize, Node.js environment.
Model.create function success at creation and return dataValues, however when I check in db, it's never been added.
What's happening behind create or is this ...
0
votes
0
answers
34
views
is it possible nestjs+sequelize@7?
I can't import @sequelize/core/decorators-legacy when using nestjs(commonjs) + sequelize@7
because of nestjs must set module type to "commonjs"
and sequelize@7 must set module type to "...
0
votes
0
answers
26
views
Issues with many to many relation with sequelize in my controller
This is my first time here, and I hope I can provide you with all the information you need.
I am using Sequelize for a project I am working on after completing my web development training. I have many ...
2
votes
2
answers
79
views
SequelizeConnectionRefusedError: Unable to connect to PostgreSQL Database in Node.js
I'm working on a Node.js backend using Express and Sequelize to connect to a PostgreSQL database. However, when I run node index.js, I get a SequelizeConnectionRefusedError.
My index.js file:
import ...
0
votes
0
answers
22
views
sequelize unknown column in having clause but generated mysql query works
I wrote following sequelize query
const result = await VendorCompany.findAll({
attributes: [
"id",
[Sequelize.fn("COUNT", Sequelize.col("Vendor->...
0
votes
0
answers
18
views
How to use the same sequelize's model but as it was a different instance?
I use Sequelize v6.x with Typescript.
My model :
class Book extends Model<InferAttributes<Book>, InferCreationAttributes<Book>> {
declare ID : number;
declare Title : string;
...
0
votes
1
answer
13
views
Sequelize.js model.save() method is not throwing ValidationError
I use the following function in an API I am building
const editUserInfo = catchAsync(async(req, res, next) => {
const userId = req.user.id;
const body = req.body;
const result = await ...
0
votes
0
answers
42
views
Pagination on high amount of rows using Sequelize and MySQL
I am using Sequelize with Node for my backend.
One of my tables is probably going to grow a lot in the coming weeks (at this moment, the table is around 1-2M rows).
I added 30M lines and added the ...
1
vote
1
answer
49
views
sequelize-typescript many-to-many on same table, include acts weird
I am implementing a social network where a User can follow another user.
So I have a Follow model:
export default class Follow extends Model {
@PrimaryKey
@ForeignKey(() => User)
@...
1
vote
1
answer
262
views
vite/electron application throws error: Could not dynamically require "sqlite3"
I am trying to integrate sequelize using sqlite3 into an electron project, I am using vite and react, but I have this problem when trying to launch the application using npm run dev.
(node:16232) ...
0
votes
0
answers
21
views
Sequlize query lifecycle watch
I am trying to debug the full SQL lifecycle.
In my NestJS project, I am using Sequelize.
I have added two hooks:
sequelize.addHook('beforeFind', (options) => {
const transaction = apm....
0
votes
0
answers
30
views
How to move ORDER BY into Subquery AFTER LIMIT without using subQuery: false? [duplicate]
How do I move ORDER BY into a subquery right after LIMIT without using subQuery: false?
This is my Sequelize query:
return await this._conversation.findAll({
// subQuery: false,
where: params....
0
votes
0
answers
31
views
Sequelize findAll() - INNER JOIN table B but return JSON result as multiple table A rows (duplicates) based on table B rows? [duplicate]
I want Sequelize to return multiple table A rows (duplicates) based on table B matches in the return JSON result with:
await this._conversation.findAll({
include: [
{
...
0
votes
0
answers
26
views
Sequelize Associations Error: "Product is not associated to CartItem" while eager loading relationships
I'm working on a Node.js project using Sequelize, and I'm encountering an error when trying to fetch associated data with eager loading. Here's the error:
Error fetching cart items: EagerLoadingError [...
1
vote
0
answers
69
views
How to Add a Conditional custom Flag in Sequelize Query?
Problem: I am using Sequelize in a Node.js application, and I need to add a new field to my query result. The new field, watchListed, should be true if a Company has more than 1 related watchlist ...
0
votes
0
answers
24
views
Resolving ER_BAD_FIELD_ERROR in Sequelize: Handling Bulk Create and Update in Node.js
I am working on a task that involves creating a new table named newtable in the database, adding the DepartmentName field from new_dev_db.departmentmaster to it, and updating the isServiceable field ...
0
votes
1
answer
20
views
Getting max of multiple columns added together in Sequelize
This is what I'm trying to replicate with Sequelize: SELECT MAX(col1 + col2 + col3) FROM table WHERE col4 = x
I'm aware of the following ways to find a max value:
let result = await Model.max('col1', ...
2
votes
1
answer
38
views
How to make multiple HasMany on the same model / foreign key in Sequelize?
Having some trouble using Sequelize V7 with the HasMany
For explaining my problem, I actually have an Item model and TextContent model.
The first one represent item with nameID and descriptionID i ...
0
votes
2
answers
34
views
How to filter associated models connected using through table and keeping all associated model
I want to filter conversations based on a user Id and get all users in that conversation. Users and conversations are joined using a through model
This is my approach
user.entity.ts
@BelongsToMany(...
0
votes
0
answers
27
views
JSON changes in the sequelize database are not applied
I'm building my discord bot on the Discord library.js and I need to make a resource system. To do this, I decided to use the sqlite3 database in conjunction with sequelize. I use json strings to store ...
0
votes
0
answers
23
views
How to Return a JSON Error Response in Sequelize with Sentry Integrated?
I'm working on an Express application using Sequelize for the database, and Sentry for error tracking. However, I'm struggling to return a JSON response with error details when an exception occurs in ...
0
votes
0
answers
69
views
How to handle transaction, locks & isolation level in sequelize?
I am trying to understand about Transaction, Lock & Isolation Level in sequelize. Say I have a route where I do multiple inserts to user table.
const transactionHandler = f => {
const ...
1
vote
1
answer
51
views
Sequelize update query resulting in error
I'm running into an issue where querying my database for an update is returning an error in my express app using sequelize. I have the following code in my controller:
I'm seeing the following error ...