12,500 questions
0
votes
0
answers
25
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
35
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
16
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
21
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
19
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
11
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
25
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
33
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
21
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
25
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
14
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
20
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
24
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
36
views
Sequelize Multipple Database
I need some help with a problem where I'm trying to create two databases, their tables, and the relationships between them using Sequelize.
The issue arises when I attempt to establish a relationship ...
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
53
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
20
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
19
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
21
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
16
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
25
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 ...
0
votes
1
answer
38
views
Sequelize Error: Restaurant.belongsTo called with something that's not a subclass of Sequelize.Model when importing Order model
I recently added a new model called Order to my project and successfully migrated it. However, the system does not seem to recognize it as a model. When I import it into my index.js file, it doesn't ...
0
votes
0
answers
13
views
Sequalize Update a column on soft delete
in paranoid table,
Can I merge these two queries into one
await activeSubscription.update({
subscriptionStatus: constants.SUBSCRIPTION_STATUS.CANCELLED
});
await activeSubscription.destroy()...
-1
votes
1
answer
40
views
Getting ERR_MODULE_NOT_FOUND in my Heroku App but working fine in localhost
Thanks for being here.
My stack
Postgres
Node 20.17.0
Express
Sequelize ORM
Javascript
When started happening?
This started happening after migrating my app from the 'require' to 'import' syntax. I ...
0
votes
0
answers
18
views
Documentation about Sequelize ignoring unknown attributes
I asked ChatGPT whether Sequelize update or create will ignore extra attributes passed to it.
I have this code and unknownField is indeed ignored. The data does not cause a db error.
const data = {
...
0
votes
1
answer
19
views
Sequelize Grouping by Associations with aliases (model->model2 AS 'alias')
I am having a problem with grouping by associated models that are using aliases.
The table on the client side has grouping, ordering, pivoting etc.
Most of it I have down, but the grouping is causing ...
0
votes
0
answers
23
views
Sequlize - Combine array contains operator with iLike
Following the example from here - https://sequelize.org/docs/v7/querying/operators/#array-contains-operator
Post.findAll({
where: {
tags: { [Op.contains]: ['popular', 'trending'] },
},
});
...
0
votes
1
answer
46
views
How to Query Bookmarked Posts Instead of Authored Posts in Sequelize
I’m new to Sequelize, so I apologize if my question seems basic. I have defined two models in my Sequelize setup: Post and User. I’m trying to query both the posts a user has authored and the posts ...
0
votes
0
answers
32
views
Problem building query sequelize-typescript
I am currently facing an issue when creating a query with sequelize-typescript. The problem arises when trying to fetch records from a many-to-many relationship. Here is the SQL query I am trying to ...
0
votes
0
answers
25
views
How to avoid the "Unknown column" error in Sequelize (MySQL)
How to avoid the "Unknown column" error in Sequelize (MySQL) when a field is missing in the database and return NULL instead of an error in production?
I am working with Sequelize and MySQL, ...
0
votes
0
answers
27
views
In nodejs (sequelize), Add new key or column in MySql via migration
In nodejs (sequelize) ,Add new key or column in MySql via migration but it is not defined in the model so how it update automatically in the model
I have make new migration on adding new column and ...
0
votes
0
answers
23
views
node js Sequelize one to many single create[Solved]
Is there anything wrong with the way the code is wrote? Because using one-tone I can insert the data normally, but when use one to many, the data is just ignored.
The idea is:
Contact Model can have ...
2
votes
1
answer
29
views
Sequelize TypeScript Error: "Property '[OpTypes.and]' does not exist on type 'WhereAttributeHash<any>'"
I'm trying to dynamically build a WHERE clause using Sequelize in a TypeScript application, but I am encountering a typing error when attempting to use [Op.and] within WhereOptions. Specifically, ...
0
votes
0
answers
22
views
Sequellize app.post show Error saving QR history: TypeError: Cannot read properties of undefined (reading 'apply')
I would like to make a post request, to save my built QR Code that I test my route to Postman. Ok,it works my QR code is saved into my database but it show this error message
Error creating QR history:...
0
votes
0
answers
32
views
Generating parameterized SQL statements with Sequelize for SQL Server
I am working with Sequelize on a SQL Server database, and I'm encountering some challenges with how Sequelize generates SQL statements for querying.
Question: is there any way to configure Sequelize ...
0
votes
0
answers
26
views
Squelize Sort By Included Model
I'm struggling to sort cases by the patients first name. I've tried nearly every possibility I feel like I could and still nothing. For some reason, it's changing the column name and then it can't ...
0
votes
1
answer
25
views
Sequelize Alias mismatch
## Product Model ##
module.exports = (sequelize, DataTypes) => {
const Product = sequelize.define('Product', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement:...
1
vote
1
answer
68
views
Sequelize transactions are very slow
I'm using sequelize with node to make a simple update endpoint that will make a couple of queries:
const update = async (req: any, res: any, next: any) => {
const t = await db.sequelize....
0
votes
1
answer
120
views
Unable to order based on joined table with Many to Many relationship
I'm trying to order a set of paged results based on the existence of many to many relationship. I can write a query by hand that does this, but I'm trying to figure out how to do this the sequelize ...
0
votes
1
answer
39
views
Sequelize: User is not associated to Commentaire
I am working with two Sequelize models: User and Comment. Each Comment belongs to a User, and a User can write multiple comments. My goal is to include all comments associated with each user in my ...
0
votes
1
answer
26
views
Is Sequelize Truncating the JSON Response with Nested Relations?
If you look at the productPGs and variantPGs relationships you notice the keys are cutoff or truncated, why is that happening? This only happens when I use include: { all: true, nested: true } in the ...
0
votes
0
answers
14
views
How to resolve TypeScript error when using generic return types with Sequelize Models
I'm working with sequelize-typescript and trying to create a generic function that returns specific model instances based on the provided model class. My setup looks like this:
import { Model, ...
0
votes
0
answers
59
views
Sequelize sync SQL Server database
I have a question regarding the sync method in Sequelize with SQL Server. To summarize the problem: I have a model with a unique column, and when the table doesn't exist or the database is empty, the ...
1
vote
0
answers
81
views
Sequelize and SQL Server
I am building a React app with Node.js and Sequelize with SQL Server. I am running into the below error. I am using the v7 alpha version of Sequelize.
My model is below:
import { Sequelize, DataTypes, ...
0
votes
1
answer
69
views
Sequelize COUNT() with HAVING clause not aliasing properly in SQL query
I need to find users with all the appropriate tags on a one to many relationship (one user to many tags)
My code:
const tags = [10,15,20];
const users = await User.findAll({
attributes: ['UserModel....
0
votes
1
answer
29
views
Sequelize with typescript defining associations
For the past three days, I've been trying to integrate Sequelize M:N (many-to-many) associations with TypeScript.
The issue arises when I follow the official Sequelize documentation, which suggests ...
0
votes
0
answers
28
views
Sequelize Error: "Dialect needs to be explicitly supplied as of v4.0.0" when using config.ts with dotenv-flow
I'm working on a Node.js project with TypeScript, Sequelize, and PostgreSQL. I encountered the following error when running my application:
ERROR: Dialect needs to be explicitly supplied as of v4.0.0
...
0
votes
0
answers
30
views
Sequelize many-to-many relation query search very slow
I use nodejs, mysql and sequelize. I have 3 model: Post , Tags and PostToTags. I add many-to-many relation between Post and Tags. Post model have title, content attributes. Tags model have title and ...
1
vote
0
answers
25
views
how arrange every attributes in a parent level attributes array
const allItems = await findAndPaginate(CartItems, req.query, {
attributes: [
["cart_items_id", "cartId"],
["cart_item_mrp", &...