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
1 answer

Foreign Key in Sequelize

I have three tables(models): Users,preferences,ideas. Users has a column 'username' as a primary key and I would like to add 'username' as foreign key to the other tables . How is it done in sequelize? I am a noob at sequelize ,so please do answer…
loksan
  • 157
  • 3
  • 17
0
votes
1 answer

Default value for database field using Sequelize migrations

It's the third day I'm trying to accomplish this simple task using sequelize but I'm having a really hard time doing it. All I want is to create a table with two fields: id (type: int) publicId (type: uuid) The id field is the primary key, auto…
Teodoro
  • 1,194
  • 8
  • 22
0
votes
2 answers

how get data from database using api?

I am beginner in nodejs and reactjs, I develope an application from reactjs and nodejs, and i use postgresql for database , when i try to fetch employeedetails by calling api in server.js that time it shows datalogs in VScode console, but If i see…
0
votes
1 answer

GraphQl , Sequelize-CLi, models bundler - sequelize.import is not a function

I'm following tutorial about sequelize-cli: https://andela.com/insights/using-graphql-and-sequelize/ And I'm getting an err: 'sequelize.import is not a function' it's coming from models/index.js (which should bundle all models) 'use strict'; const…
kasia
  • 288
  • 2
  • 6
  • 23
0
votes
1 answer

sequelize migration doesnot read dotenv variables

When I start server, it connects to database well. In my case the command is nodemon But when I try to migrate. the command is npx sequelize-cli db:migrate I got connect ECONNREFUSED error. I found that the problem was process.env If I put in the…
byyoung
  • 327
  • 3
  • 10
0
votes
0 answers

Updating instance with multiple associations in Sequelize

I am able to create records in my MySQL DB with sequelize and NodeJS. But now I am trying to update records in my Database. I have NodeJS as backend and my DB is MySql. Sequelize is my ORM. In Sequelize 5, I have a couple of classes: WorkOder, User…
PeteBaser
  • 263
  • 1
  • 5
  • 15
0
votes
1 answer

use model in "sequelize" from a controller

I'm using a model created by sequelice-cli, but when I use it, I get an error message. I am using an ORM (sequelize) and when I try to access the methods of the model, for example finOne(), findAll(), update(), it does not recognize it and throws an…
ChrisDLH
  • 123
  • 1
  • 2
  • 9
0
votes
0 answers

sequelize migrations not connecting to database?

I'm not a sequelize expert, but I'm working on a project with other people where we're using sequelize with postgres. I'm trying to run a migration using sequelize-cli, but for some reason, the migration just simply won't run, but it also doesn't…
ditao1
  • 11
  • 3
0
votes
1 answer

Creating instance with multiple associations in Sequelize

I have NodeJS as backend and my DB is MySql. Sequelize is my ORM. In Sequelize 5, I have a couple of classes: WorkOder, User (mechanic), Customer, Client and ExpertiseOffice. My datamodel is not complex, there are only 1:1 relations. A WorkOrder has…
PeteBaser
  • 263
  • 1
  • 5
  • 15
0
votes
1 answer

When i use the literal of the sequelize, there's no result

example: attributes: [ db.sequelize.literal('COUNT(1)') ], If i use it, a log is created. (Executing (default): SELECT COUNT(1) as cnt FROM TEST AS A; If this log was copied and used in the database, the desired results could be obtained…
Jun Mr.
  • 21
  • 2
0
votes
1 answer

Counting a column's data in Sequelize

I have two tables associated with each other in Sequelize and I want to count the following Jobs table columns: 'id', 'name' worker table colmuns: 'id', 'name', 'job_id' Lets say we have 5 jobs available right now and lots of workers associated…
Angels
  • 325
  • 4
  • 15
0
votes
1 answer

How do I setup model for table object with arrays of responses in sequelize

I am having challenge on how to setup model for table object with arrays of responses in Sequelize ORM. I use Postgres DB. I have a table say foo. Foo has columns A B C > C1_SN C1_Name C1_Address C1_Phone D E The column C has a boolean…
Medico
  • 45
  • 1
  • 2
  • 11
0
votes
1 answer

Why I can't add a new column in sequelize-cli?

To add a new column 'avatar' to the table named 'vdo' I just create a miguration file and run it: module.exports = { up: (queryInterface, Sequelize) => { return queryInterface.addColumn('vdo', 'avatar', { type: Sequelize.STRING, }); …
legend
  • 59
  • 5
0
votes
1 answer

Sequelize especial methods don't get created when Using sequelize migrations

I am struggling when using sequelize migrations and a many-to-many relationship between Users and Roles. This is the Users model: 'use strict'; module.exports = (sequelize, DataTypes) => { const user = sequelize.define('Users', { username:…
vhbazan
  • 1,240
  • 1
  • 17
  • 26
0
votes
1 answer

How to replace multiple lines in a file (or multiple files)?

One of my favorite utilities, sequelize, will automatically generate models from a database. However, it does not always recognize auto-increment functions on primary keys. This causes the model to sometimes generate wrong and causes errors when…
Fred Lackey
  • 2,351
  • 21
  • 34