Questions tagged [sequelize-cli]

The Sequelize Command Line Interface (CLI) supports for migrations and seeders.

The Sequelize Command Line Interface (CLI) supports for migrations and seeders.

With migrations and seeders it's possible to transfer an existing database into another state and vice versa: those state transitions are saved in migration storage and seeder storage accordingly, which describe the way how to get to the new state and how to revert the changes in order to get back to the old state.

Useful links:


Related tags:

499 questions
0
votes
0 answers

Models connection thorough Sequelize

I have model User in Postgres. Each user has Skills (Skill is also an existing model). There are 2 categories of skills: known and learning. What relations should I use to have possibility take both Known and Learning skills?
0
votes
1 answer

Sequelize Include doesn't work without results

I'm doing the select below and it works great when it has results to return, when I it doesn't i have an error like this TypeError: Cannot read property 'id' of null This only occcurs when they city doesn't have any marker, otherwise it works as…
John
  • 1,697
  • 4
  • 27
  • 53
0
votes
2 answers

how to retrieve all records from sequelize PostgreSQL except a specific value?

I want to retrieve all the records except a specific value, I tried the below query but I am not getting the required output. db.owner.findAll({ exclude: { model : models.owner.name: 'jack'}, include: [{ model: models.customer, as: 'customers'…
Trang D
  • 333
  • 5
  • 16
0
votes
1 answer

How to get data in sequelize using Noje js

This is code i have used, fetched the all data in database, but i have not getting in value. I'm new for sequelize. Project.findAll({ raw: true}).then(function (users) { console.log(users); console.log(users.dataValues); …
suresh t
  • 37
  • 1
  • 9
0
votes
1 answer

Issue with Sequelize seeding Dialect error

I'm trying to seed my database with an npm script. "scripts": { "devstart": "set NODE_ENV=development && sequelize db:seed:all && nodemon ./server.js" } I keep getting an error saying that I have to explicitly define the dialect in my…
0
votes
1 answer

Constraint self referencing foreign key to limit nesting (SQL, Sequelize)

I am trying to make a table for example which consists of this structure: id(PK, int) comment_id(FK, int) body(text) 1 null "This is a comment" 2 1 "This is a nested…
moodseller
  • 212
  • 2
  • 14
0
votes
2 answers

Sequelize nested eager loading does not load both records associated with the same model

I am trying to have an api route return a large object with nested eager loading in sequelize. My "Lane" model has two associations to the "Location" model as 'origin_location_id' and 'destination_location_id'. I am trying to return both the…
0
votes
1 answer

How to find data of source table from target table in sequelize?

I have two tables, traders, and messages Traders is associated to messages as following traders.hasMany(models.messages, {as: 'sender',foreignKey : 'senderId'}); traders.hasMany(models.messages, {as: 'reciever',foreignKey : 'recieverId'}); now when…
Faizan Ul Haq
  • 454
  • 2
  • 7
  • 23
0
votes
3 answers

How to removeConstraint defaultValue in Sequelize

I'm trying to write a migration in Sequelize and want to remove the defaultValue constraint. What is the proper syntax? I've tried both of the following: return queryInterface.removeConstraint('Table', 'table_columnName_default') return…
0
votes
1 answer

Sequelize - Is there a way to automatically generate models and their associations from an existing database?

Is there a way to generate models and associations (through automation) based on an existing database? For example, take customers and orders: Customer --------- id, name Order --------- id, customerId, orderDate
Rod
  • 14,529
  • 31
  • 118
  • 230
0
votes
0 answers

How can I parse a NUMERIC(20) using sequelize before it converts the value to int

I'm using mssql and my table have a NUMERIC(20) field. I'm trying to convert it to string on the get function but the this.getDataValue('code') is returning a truncated int (8985353050864662000) code: { type: DataTypes.NUMBER(20), get() { …
0
votes
2 answers

Why is Promise returned in sequelize

I am new to sequelize. So, I am writing a query where I map the parameters and find them in the db. But all I am getting is a Promise. Here's my code findData(params) { return params.map(product => { return Model.Stock.findAll({ raw: true…
Anita
  • 476
  • 3
  • 10
  • 24
0
votes
0 answers

Sync local mysql with remote mssql

I'm developing a website with nodejs and mysql. My client has got an sql server database in their buildings. The sql server DB is the main data source but it can not be used as the website's data source. So I have to regularly sync the two. Any…
0
votes
2 answers

Sequelize migrate failing due to dialect object Object not supported error

Background I am creating a boilerplate express application. I have configured a database connection using pg and sequelize. When I add the cli and try to run sequlize db:migrate I get this error, ERROR: The dialect [object Object] is not supported.…
wuno
  • 9,547
  • 19
  • 96
  • 180
0
votes
1 answer

sequelize custom validator

I would like to create custom field validator with reference to existing field. What I did is to create a custom validator: const User = sequelize.define('User', { postalCode: { type: DataTypes.STRING }, country:…
agims7
  • 216
  • 2
  • 6
  • 16