12,493 questions
0
votes
0
answers
11
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
0
answers
36
views
How to solve the microservices with foreign key constraint? [closed]
I am working with micro services: product service, order service, auth service and so forth. Each service has a database table, for database I am using PostgreSQL with sequelize.
Now the problem I am ...
0
votes
1
answer
27
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
59
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
38
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
21
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
36
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
50
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
30
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
21
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
25
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 ...
0
votes
1
answer
60
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
21
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
16
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
38
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
43
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
112
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
68
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
19
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
33
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
32
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
23
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
21
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
50
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
48
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 ...
0
votes
0
answers
19
views
Nested dependencies in mono-repo not found even though they're there
I have a monorepo that uses several local packages via links in package.json
The setup works fine except for one issue, Sequelize. Sequelize has problems if you have multiple packages including it
as ...
0
votes
1
answer
91
views
Sequelize: missing FROM-clause entry for table
I'm using Sequelize to make a pagination query with QuizModel. My query will include 2 models QuizCategoryModel, QuizInfoModel. My where condition in parent model (QuizModel) includes a reference to
...
0
votes
1
answer
31
views
null value in column "id" of relation violates not-null constraint with AutoIncrementIdentity via Sequelize
i've created a migration file and state field to be like the following.
for an example "project" table , then i ready a seed file , but because of the following error that cause seed failure
...
0
votes
0
answers
13
views
Issue connecting Codebuild to RDS (Sequelize command)
I'm getting the following error in Codebuild when trying to connect to local RDS instance.
Tried adding inbound rules to RDS for all Codebuild IPs listed in AWS from the documentation below and no ...
0
votes
0
answers
27
views
Intermittent Connection Issues with Sequelize Migrations in Docker Compose Setup [duplicate]
I am using Docker Compose to set up my application, which consists of three services: a MySQL database, a backend API, and a Vue.js frontend. My backend uses Sequelize for database migrations.
However,...
0
votes
1
answer
40
views
Sequelize create() not working for inserting an order, but manual SQL query works
I am trying to create an order using Sequelize in my Node.js app, but I'm encountering issues with both the Order.create() method and a manual INSERT INTO query.
Here is the code I'm using to create ...
0
votes
1
answer
23
views
Can sequelize have self ref column to support a child parent relationship within the same table?
does seauelize support self reference tables?
For example, if I have a table called product, and logically, it has child / parent relationships with its self, so I defined a parent_id column that has ...
0
votes
0
answers
27
views
How to extract actual database error instead of the generic transaction aborted error in Postgresql Sequelize transaction
I am using transaction in my sequelize-typescript for creating a record which looks like this
return await this.sequelize.transaction(async (transaction) => {
const borrower = await this....
0
votes
0
answers
20
views
Sequelize ORM: Dynamically set database schema for sequelizeInstance (or repositories) at runtime?
For our SaaS API we use schema-based multitenancy, which means every customer (~tenant) has its own separate schema within the same (MySQL) database, without interfering with other customers. Each ...
0
votes
0
answers
21
views
Problem uploading image from express to s3
I want to upload an image to s3 but cant, eventhough a similar api like that can work normally.
exports.createPost = async (req, res) => {
const { user_id, title, caption } = req.body;// ...
0
votes
0
answers
25
views
Sequelize Adding Association Causes Always Alter
I am trying to add multiple associations to my project. Although, other tables do not giving this error or misusage effect these associations makes the project always alter.
db.option.hasMany(db....
0
votes
0
answers
21
views
Sequalize associating one model on an RDS database and an Aurora database
I tried to associate a model with 2 different databases that have this same table, one in an aurora db and another in a RDS db using sequalize. They have a different schema name but the same table ...
0
votes
0
answers
24
views
Sequelizer belongsToMany relations
I am trying to establish a belongsToMany relationship between two models, User and Company.
I think I have done everything right, but the funny thing is that the api shows me the results relationships ...
1
vote
0
answers
75
views
Please install sqlite3 package manually
I get an npm error from the sequelize module when running the project via node:
"start": "node build/scripts/main.js"
webpack-internal:///../../node_modules/sequelize/lib/dialects/...
0
votes
0
answers
28
views
Is posible install old version of adminjs
I'm searching an admin template for an application based on NodeJs+Express+Sequelize.
I find Adminjs that seem like very usefull for my purpose, but i read in documentation that is deprecate Js syntax ...
1
vote
0
answers
23
views
Error Occurs When Configuring Passport Session Store in Express.js with Sequelize and PostgreSQL
I am using Passport for authentication in my Express.js project. The database and ORM I am using are PostgreSQL and Sequelize, respectively.
While configuring session.use() for session handling, I ...
1
vote
0
answers
32
views
Sequelize associations with multi-tenant (schemas) solution
I'm rather new to backend development, so bear with me.
I have a 'partners' table in the 'public' schema and each partner has their own schema like 'partner_1', 'partner_2', etc...
Their schemas ...
1
vote
0
answers
20
views
SequelizeAssociationError: Conflict in defining HasMany and BelongsTo relationships between User and Friends models
I am trying to define a HasMany and BelongsTo relationship between my User and Friends models in Sequelize. However, I am encountering the following error when I start my server:
AssociationError [...
0
votes
0
answers
27
views
Using Sequelize to define a 1:m relationship between two models (+ creating migrations)
I am confused on the intended workflow with Sequelize. I have found some documentation that refers to a workflow that uses sequelize-cli, while others seem to create bespoke one-off javascript scripts ...