Questions tagged [sequelize.js]

The Sequelize library provides an ORM (Object-Relational-Mapper) for Node.js, written entirely in JavaScript. Provides easy mapping for MySQL, MariaDB, SQLite, PostgreSQL and SQL Server.

The Sequelize library provides an ORM (Object-Relational-Mapper) for Node.js, written entirely in JavaScript. Provides easy mapping for , , , and .

It's well maintained and has lots of built-in features for dealing with the database, including transaction support, relations, eager and lazy loading, read replication.

Features

  • Schema definition
  • Schema synchronization/dropping
  • Easy definition of class/instance methods
  • Instance saving/updating/dropping
  • Asynchronous library
  • Associations
  • Importing definitions from single files

Useful links


Related tags :

12347 questions
3
votes
1 answer

sequelize find and update a record without a model

I would like to update a database record using sequelize.js and mysql2 I do not have access to the models folder or either they have not been made so is there a way to update can't find solution all solutions are that i checked are with model name…
Muhammad Sharif
  • 406
  • 6
  • 17
3
votes
1 answer

Sequelize - Multiple Op.Or operations for the same field

How do I create a Sequelize filter that will check for multiple ranges of the same field. In simple SQL query this would have been a straight forward thing to day but proves to be a bit tricky in Sequelize. I have tried few things but not getting…
Siv
  • 31
  • 1
  • 2
3
votes
2 answers

Sequelize: instance.get is not a function

I have this code that queries all the data under my feedback model const result = await models.Feedback.findOne({ include: [{ association: models.Feedback.Point, order: [["date_saved", "DESC"]], //…
Techuila
  • 1,237
  • 8
  • 12
3
votes
1 answer

Counting join with sequelize with multiple includes

I'm using the count method of mysql in sequelize but when I have multiple nested includes the count attribute makes the request returns less results. The problem is the same with the sum method. I tried with the attributes group and duplicate but…
Simon
  • 39
  • 1
  • 1
  • 2
3
votes
2 answers

Symbol to string with JSON.stringify

I need to convert a Symbol to string in order to create a unique key in Redis, but I can't. I've already tried to use Object.toString(obj) and String(obj) but I get errors or [Object] results¡. This is the controller const name =…
alvarocece
  • 41
  • 4
3
votes
3 answers

How do I set a default value or options of a Foreign Key in a 'BelongsTo' association in Sequelize?

I have a seemingly common problem with sequelize. For context I am trying to assign a default role to each user that is created. Essentially each user's role should be set to default user when they are first registered. I would like to be able to…
Michael Sorensen
  • 1,850
  • 12
  • 20
3
votes
1 answer

how to merge response attributes of other table in node js

I have 3 Tables User, Cars and UserCars User{id, name, phone, email} Cars{id, name, manufacturer} UserCars{id, car_id, user_id, role} User have many cars(through UserCars) Cars have many users(through UserCars) I am using express js …
Dom
  • 404
  • 6
  • 12
3
votes
1 answer

Sequelize findAll() with where-parameter returns null while findByPk() returns correct data

I'm setting up resolvers for a GraphQL API right now and running into some problems/questions regarding the findAll() function from sequelize. I have these 2 resolvers: User: async (parent, { id }, { models }) => { return await…
Mathis Witte
  • 180
  • 13
3
votes
8 answers

ERROR: "Please install sqlite3 package manually" when I execute "sequelize db:migrate"

I'm trying to create a sample app, using this article: https://arjunphp.com/restful-api-using-async-await-node-express-sequelize/ But when a try to execute database migration with sequenze-cli on sqlite, a have always the same…
3
votes
1 answer

Run Sequelize migration files from separate third-party Node module?

I am working on third-party NODE module which deal with sending emails and storing them in DB, so let's call it mail-module. In order for someone to use its functionalities, it should be enough to import it in his project and use its functions for…
milosdju
  • 783
  • 12
  • 27
3
votes
1 answer

Cant figure out what is wrong with my models

I set up my db like: const Sequelize = require("sequelize"); const db = {}; const sequelize = new Sequelize("sequel", "root", "root", { host: "localhost", dialect: "mysql", pool: { max: 5, min: 0, acquire: 30000, idle: 10000 …
Bipin
  • 89
  • 2
  • 13
3
votes
1 answer

Sequelize is not returning queryAsync object

I'm building up nodejs api by using async await.So my controller every function is async which receives a promise by model. For query i have used the sequelize package for interacting with the database. for using sequelize async query behaviour i…
truesource
  • 397
  • 3
  • 20
3
votes
1 answer

Associate in Sequelize not working as intended

I am trying to associate two tables in Sequelize but I am getting the SequelizeEagerLoadingError that one table is not associated to another despite trying all the available fixes on this platform. I have two tables, User and Item. User…
Rotiken Gisa
  • 380
  • 2
  • 12
3
votes
4 answers

Sequelize raw queries TextRow and getting data out of it

Given this query here, let output = []; const sql = `select * from coredb.account LIMIT ${offset},${limit}`; let data = await sequelize.query(sql, null, {raw: true, type: sequelize.QueryTypes.SELECT}); …
RedactedProfile
  • 2,748
  • 6
  • 32
  • 51
3
votes
1 answer

Getting "TypeError: Cannot read property 'findAll' of undefined" with Sequlize

I'm working on a simple CRUD Application with PostgreSQL, Sequelize and Express. And following this tutorial as a reference. There seems to be an issue with my model or db connectivity. Please find below details: Folder structure: server |__config…
88dax
  • 307
  • 1
  • 6
  • 14
1 2 3
99
100