12,496
                questions
            
            
            0
            votes
        
        
            0
            answers
        
        
            20
            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
        
        
            21
            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
        
        
            25
            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
        
        
            18
            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
        
        
            18
            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
        
        
            22
            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
        
        
            22
            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
        
        
            37
            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
        
        
            116
            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
        
        
            36
            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
        
        
            21
            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
        
        
            12
            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
        
        
            56
            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
        
        
            71
            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
        
        
            54
            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
        
        
            27
            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
        
        
            24
            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
        
        
            28
            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", &...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            13
            views
        
    Sequelize Many-to-Many on same table
                I have a user:
@Table({
    underscored: true,
})
export default class User extends Model {
    @PrimaryKey
    @Column
    id: string;
    @AllowNull(false)
    @Column
    name: string;
    @...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            24
            views
        
    I want to Find data in Sequelize that createdAt and UpdateAt same Consider only date Not date time
                const StudentAssessmentTransaction = sequelize.define(
      "studentAssessmentTransaction",
      {
        id: {
          type: DataTypes.INTEGER,
          allowNull: false,
          ...
            
        
       
    
            -2
            votes
        
        
            0
            answers
        
        
            14
            views
        
    Seuqlize won't execute query that works fine on MySQL Workbench [duplicate]
                I'm working on an Express application using Sequelize to query a MySQL database. I have a route that retrieves the closest restaurants based on user-provided latitude and longitude. While the SQL ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            13
            views
        
    How to search substring inside array of string sequelize? [duplicate]
                I use sequelize and mysql. Here question. For example I hava column name: DataTypes.JSON . for example i have these data: [ {id:1, name:['mother','adad','asd',...],... }, {id:2, name:['sister','as',..]...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            30
            views
        
    Always Encrypted SQL Server with Sequelize
                I'm testing to encrypt some data using always encrypted, but I'm having problems with comparison queries.
Sequelize:
mapDatabases.forEach(async (row) => {
        let model = row.model
        let ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            16
            views
        
    Dynamically call sequelize models using tablename
                I have to call sequelize models dynamically using the tablenames, also include their associations dynamically. Is there a way to do this? Is it possible?
I have got the models dynamically but not ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            25
            views
        
    ReferenceError: Cannot access 'ProductCategory' before initialization in sequelize-typescript with Nestjs
                I am trying to use Sequelize + Postgres with Nestjs, and I've defined few Models in different resources, and having HasMany, HasOne relationships with BelongsTo() in the ForeignKey Table, but I am ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            16
            views
        
    Sequelize doesn't fetch the assosiated model with a GET request
                Sequelize doesn't fetch the assosiated model in the get request, but it works in the POST and DELETE requests with two parameters provided. I have an M-M relationship between the Worker and Owner id(...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            42
            views
        
    Connection denied with MYSQL db when node app dockerized [duplicate]
                I have a problem with connecting my node app container to MySQL database. When -compose up I keep getting error from container logs:
server-1  | Unable to connect to database AccessDeniedError [...
            
        
       
    
            -1
            votes
        
        
            1
            answer
        
        
            22
            views
        
    Is encoding required to properly store any Unicode character in a PostgreSQL database, using sequelize in typescript?
                I have a typescript project which connects via sequelize to a PostgreSQL database. All string columns in all tables in the database are TEXT type, which as per PostgreSQL documentation, support ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            33
            views
        
    sequelize error when filtering nested columns using the '$nested.column$' syntax
                I am trying to add anyField filter logic to my generic controller list method for my expressjs app using sequelize for my db logic and I can't figure out how to fix this:
I am passing in the ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            26
            views
        
    How to setup nextjs and sequelizejs for Microsoft SQL Server with dialectOption Authentication=ActiveDirectoryPassword
                I have to setup sequelizejs connection with Microsoft SQL Server. With Dialect option Authentication=ActiveDirectoryPassword
I have tried the following option:
host: '{redacted}.database.windows.net',
...
            
        
       
    
            2
            votes
        
        
            0
            answers
        
        
            50
            views
        
    Typescript module augmentation with third party library
                I have a typescript server project using a third party plugin called ah-sequelize-plugin. It requires that I create config files that augment/add to their config files.
Here is an example of one of ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            25
            views
        
    How to prevent requests from altering database at the same time?
                I have two requests from the client that can be held pending and executed simultaneously for a user. The two requests check the user's balance; if sufficient, it decrements the balance and then ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            22
            views
        
    sequelize-typescript addColumn with 'after
                I'm creating a column with sequelize with mysql/mariadb. Looking into the DOCs, it is possible to create this column after another column just defining an after attribute in third parameter, but when ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            39
            views
        
    Sequelize (with NextJS) sync() twice
                I am using Sequelize with nextjs. During the DELETE operation, it performs sync() twice. Is this a problem or is it normal?
I am sharing my codes below.
// sequelize.ts
import { Sequelize } from '...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            34
            views
        
    How to Require User ID for Liking a Post in a React and Express Application?
                I'm developing a web application using React for the frontend and Express for the backend, and I want to implement a feature where users must be authenticated (and their user ID verified) to like a ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            20
            views
        
    Error: EagerLoadingError [SequelizeEagerLoadingError]: Client is not associated to Job
                I'm trying to create database associations using Sequelize, but when I try test them I get an error saying that there are no associations. I've tried moving the order of the models and other code, but ...
            
        
       
    
            1
            vote
        
        
            1
            answer
        
        
            55
            views
        
    Fields with the 'declare' modifier cannot be initialized here, but only in the constructor
                I don't even know where to begin or what to look for with this one.
I'm upgrading an old React, Node, Express full-stack application, and one of the steps I'm taking is adding TypeScript. The project ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            22
            views
        
    TypeError: values.map is not a function when trying to query in sequelize using operator (Op)
                So I was trying to make a function that will sort table that I have by using multiple parameters,  so that i can filter the table data, the parameter will be passed as JSON, something like this
{
    &...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            25
            views
        
    Using Sequelize bulkCreate as a bulk update
                We have a node project with Sequelize and postgresql, and I need to improve the performance of some endpoints. And there are several cases in the code where an update query is made for each row (with ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            27
            views
        
    How to perform a one-to-one migration
                I have a particular case where I have a promotion and a survey attached to it. The thing is don't want the promotion to have FKs for surveys as the surveys can be optional, but I also don't want to ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            37
            views
        
    Sequelize findAndCountAll: Pagination and Search Conflicts with Subquery in hasMany Relationship
                Texperts.findAndCountAll({
        subQuery:false,
        where:{
          ...(searchKey && {
            [Op.or]: [
              { '$user.full_name$': { [Op.like]: `%${searchKey}%` } },
   ...
            
        
       
    
            0
            votes
        
        
            1
            answer
        
        
            25
            views
        
    Sequelize column region.region_id does not exist error
                What am i missing? any help is appreciated. Thanks
facility migration file
await queryInterface.createTable("facility", {
      id: {
        allowNull: false,
        autoIncrement: true,
  ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            36
            views
        
    sql error, Saying theres no relations between tables but I cant figure out why
                I have a database for a DnD builder webpage.
We want to make an application that when the user selects a radio on the webpage it will pull the corresponding information from the database and display ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            26
            views
        
    Sequelize syntax error at or near "ON DELETE" when using associations
                I've created a simple express app with a Postgres database using Sequelize as the ORM to define my models.
I have two models where there is a one-to-many relationship:
A Faction can have many Craters
...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            24
            views
        
    How to extend sequeulize model with typescript?
                Sequelize V° 6.37.3
sequelize-typescript V° 2.1.6
I try to extend a sequelize base model. My layout conatins 2 models: Examination (parent) and ConcreteExamination (child).
examination.ts
import { ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            19
            views
        
    How can I get my bluehost mysql server to work with react js, express / sequelize application? [duplicate]
                While testing my application locally, I am able to create a database and populate it. When I try to use the app in production, it gives me a JSON error. I have created a user with password and granted ...
            
        
       
    
            0
            votes
        
        
            0
            answers
        
        
            17
            views
        
    react sequelize post adding values duplicate
                I am using sequelize in combo with react to store, update and delete data in mysql.
Now I have users and some roles. And a table that stores the roleId and userId if a user has a specific role.
E.g.: ...