12,505 questions
1
vote
0
answers
19
views
How to Add a Conditional custom Flag Based on COUNT 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
20
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
16
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', ...
-4
votes
0
answers
26
views
POSTGRES PG CRYPTO [closed]
{"error":"invalid byte sequence for encoding "UTF8": 0xc3 0x0d"}
i am able to figure out that I need to change column to bytea but that is hectic for me because I have ...
-2
votes
0
answers
23
views
Adding photos taken by phone camera to database [closed]
I’m looking for a way to add photos captured using a mobile phone to mysql database.
The Angular on change event it adds the photos to the database and it saves them to the correct folder but it doesn'...
-1
votes
0
answers
52
views
Error: SQLITE_ERROR: no such column, but column actually exists?
I'm trying to translate this SQL query into sequelize:
SELECT
Profile.profession,
SUM(Jobs.price) AS total_earned
FROM
Profiles AS Profile
INNER JOIN
Contracts AS Contractor ON Profile.id = ...
2
votes
1
answer
27
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
28
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
20
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
26
views
Adding photos to database with Angular and mysql [closed]
Hi I’m looking for a way to add photos captured using a mobile phone to mysql database.
The Angular on change event it adds the photos to the database but the name is NULL and it saves them to the ...
0
votes
0
answers
17
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
33
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
37
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
30
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
22
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
35
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
38
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
56
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
22
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
24
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
46
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
19
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
34
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
26
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
32
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
23
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
76
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....