506 questions
-1
votes
2
answers
56
views
sequelize relationships Cannot read properties of undefined (reading 'hasMany')
I'm trying to integrate sequelize with the db conection to postgres and i am getting an error where relationships are built.
i don't know if i'm missing something at this point
index.js
'use strict';
...
1
vote
0
answers
31
views
Cannot generate model using sequelize-cli enum with defaultValue
My sequelize-cli is
npx sequelize-cli model:generate --name Profile --attributes username:string,imageUrl:string,fullname:string,dateOfBirth:date,UserId:UUID,role:enum:'{staff,admin}':defaultValue:...
0
votes
1
answer
74
views
Using import vs require with Node and Sequelize
I'm using type module/import syntax for the rest of my project, but the Sequelize CLI generates files with require syntax. How should I handle this? I'm already having trouble with not being able to ...
1
vote
1
answer
57
views
Netlify app can't login to Express app only on mobile
I have a Vue 3 app hosted on Netlify, and the backend is hosted on Heroku. The login is a simple /login endpoint made with Express and Sequelize. It works well on desktop, but when I try to log in on ...
0
votes
0
answers
32
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
56
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
1
answer
33
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
Error Implementing Lifecycle Hooks for Password Hashing with Sequelize-Typescript
I am working on a Node.js project using Sequelize-Typescript, and I'm trying to hash user passwords using lifecycle hooks (BeforeCreate and BeforeUpdate). However, I encounter an error related to how ...
0
votes
0
answers
114
views
SequelizeConnectionError: role "node" does not exist
I have integrated sequlize into my NextJS project. Also, write the migration script for the schemas to be created into PostgreSQL. But, at the time of POST api call I am receiving the error saying: &...
0
votes
1
answer
71
views
Getting error in fetching data with Sequelize for Mysql Database (Backend Node.js)
I am using Sequelize ORM with mysql database for nodejs application. Somewhere I am stuck with one api whose job is just to show list based on the queryparam values. Issue is when I am not applying ...
1
vote
0
answers
41
views
SequelizeCLI: Cannot read properties of undefined (reading 'findAll')
I'm trying to build a simple next.js app using Sequelize CLI. However, there are issues with querying the database (migrations are run and all so DB connection is good).
For instance:
import { ...
0
votes
1
answer
392
views
How to fix sequelize 'npx sequelize-cli db:migrate' from docker-compose.yml?
I am facing
Sequelize CLI [Node: 21.7.1, CLI: 6.6.2, ORM: 6.37.1]
|
| Loaded configuration file "database/config/config.json".
| Using environment "production".
| ERROR: Access ...
0
votes
1
answer
748
views
Cannot read properties of undefined (reading 'use_env_variable') when connect to DB
I'm trying to connect the DataBase with Sequelize and NodeJS but an error happen and I can't connect to DB. Through inspection I see that the 'config' variable is null and 'config.use_env_variable' ...
0
votes
0
answers
97
views
sequelize: How to count a select subquery
I dont know how to create a non-raw query using sequelize like this:
SELECT
COUNT(res.id)
FROM
(
SELECT
clients.id,
COUNT(client_addresses.id) AS total_client_addresses
...
0
votes
0
answers
64
views
InnoDB - errno: 1005, sqlState: 'HY000' sqlMessage: "Can't create table (tableName) (errno: -1)",
I was trying to make club, and students database
I am using sequelize, my engine is innoDB
and I wrote like this
module.exports = (seq, DataTypes) => {
const Club = seq.define("clubs",...
0
votes
1
answer
120
views
Sequelize-cli db:drop and dp:create not working
I'm trying to docker compose up a test version of a node.js app, and using sequelize-cli commands to create/migrate/seed the mysql database.
While db:migrate works just fine (after I manually create ...
1
vote
1
answer
186
views
Running migrations (sequelize), on Azure database
I need to run the migrations to create the tables in my database, currently my database is on an azure MySQL server, how do I run the migrations from my local host?
Currently when I run the command it ...
0
votes
1
answer
521
views
Sequelize-cli db:create Cannot read properties of undefined (reading 'replace') when creating DB
I was using sequelize-cli to create postgresql DB using the command:
npx sequelize-cli db:create.
My config.js file is
const dotenv = require('dotenv')
dotenv.config()
module.exports = {
...
0
votes
0
answers
41
views
Bug when testing the setup of Model and Migration connection
I'm currently doing a backend connection with a db, using node, postgresql and sequelize as orm. I've been getting the same error when I try to make a test using the route and creating a static user, ...
0
votes
1
answer
37
views
Cannot select multiple tables using sequelize
I was very confused in selecting employee and leave data using the master number contained in both tables. Can someone help me, here is code:
karyawan model file:
'use strict';
module.exports = (...
1
vote
1
answer
119
views
Sequelize migration is being applied however there is no change to the database
I have a simple migration that renames a column. The migration file looks like this:
const tableName= 'aTable';
module.exports = {
up: async (queryInterface, Sequelize) => {
...
0
votes
1
answer
202
views
How to disable sequelize cli log - Sequelize CLI [Node: 10.21.0, CLI: 6.0.0, ORM: 6.1.0]
I am using sequelize cli to configure postgresql and run migrations/seeders. There are a couple of logs being printed unnecessarily and might also reveal internals of my service. I would want to ...
0
votes
0
answers
57
views
Why not able to create records in sequelize models?
I am using sequelize models and created City model using the sequelize-cli. The model and table is getting created after applying the migration. I have also created a repository for creating records ...
0
votes
0
answers
99
views
Sequelize Object is possible undefined
I am trying to read a read only DB on a server.
I was able to generate the models in TS files using the command
sequelize-auto -o "./models" -d myDB -h webHostAddress -x Pwd -u root -p 3306 -...
0
votes
0
answers
93
views
findOne returning me null even though there is entries in my DB NodeJS
This is my User Model
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define("User", {
email: {
type: DataTypes.STRING,
...
0
votes
1
answer
513
views
GitHub Actions - Sequelize Migration Error: password authentication failed for user 'runner'
This is my workflow:
name: Run Tests on Pull Request
on:
pull_request:
branches:
- develop
- staging
- production
jobs:
test:
runs-on: ubuntu-latest
services:
...
0
votes
0
answers
22
views
How to store courses data safely and with the best way for easier adding/reading/removing - sequelize & NodeJS
What is the best way to store courses the user enrolled in and his progress and every lesson he finished and the time he stopped on, is that will be as a column in user table with
Sequelize.ARRAY(...
0
votes
0
answers
157
views
How to change collation for a column in SQL Server using changeColumn in a migration
The Sequelize changeColumn() function appears to exist and is referenced in e.g. this answer but the method there does not work for me (running V6). There is no documentation for changeColumn() on the ...
0
votes
0
answers
148
views
How to seperate schema and table in the raw query string in Sequelize Migration
I'm trying to create a table using Sequelize migrations with a foreign key reference to a table in a seperate schema in my database. The issue appears to be that sequelize builds the query with the ...
2
votes
0
answers
759
views
.sequelizerc with ESM modules doesn't work with @babel/register and @babel/preset-env
If I change in .sequelizerc file babel packages to @babel/register and @babel/preset-env sequelize CLI stops working (the following code works as is).
require("babel-register")({
presets:...
0
votes
0
answers
92
views
Is it possible to set a sequelize model column's value based off the input of another column?
In the code below, can I set "isPrimary" based on the value of "name"?
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
...
0
votes
0
answers
113
views
Why does Sequelize say the table doesn't existed if I've already defined the model?
I'm using a SQLite3 database with Sequelize as an ORM. I have one model/table in the database named "cities" which I created before I set up sequelize-cli so there's no migration file that ...
0
votes
0
answers
40
views
Sequelize joins using model query , DB is postgres
I have two tables "Table 1" and "Table 2". I am using nodejs and DB is postgres
Table 1
| id | createdOn |
| -------- | --------------------------|
| 1 ...
0
votes
1
answer
124
views
Can we generate migrations using sequelize-cli automatically from a model just like we do in django-rest-framework
I'm using sequelize-cli, and generating migrations but we have to add the definitions and constraints manually even though we have already defined all of that in the model file.
I've worked in django-...
1
vote
0
answers
132
views
How to generate SQL code representing a db migration?
Locally, I run yarn run migrate --name filename.js to run a specific database migration. In package.json I have:
"scripts": {
"migrate": "tsc && npx sequelize-cli ...
0
votes
1
answer
66
views
Sequelize associations not working when including to findAll
I have two models Category and Product.
The product can have one Category, Category can have many products.
This is a One-to-Many relationship.
product.js file:
import { DataTypes, Model } from '...
0
votes
1
answer
927
views
Do I need to generate migration file every time I wanted to make some changes in existing table?
I am trying to rename some columns in table and also wanted to add some new fields but Even I change the code in migration file of that table it's not reflecting any changes in the table.
"No ...
0
votes
1
answer
883
views
sequelize migration with transactions not working
module.exports = {
async up(queryInterface, Sequelize) {
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.addColumn(
'Person',
...
0
votes
0
answers
225
views
Sequelize cli error this.lib.database is not a constructor
Getting this error using sequelize cli for migrations it was working previously but dont know why it isnt now and there is no details to this error
sequelize db:migrate:undo:all
Sequelize CLI [Node: ...
0
votes
1
answer
195
views
Sequelize migration with testing
I published my application couple months ago. Now I got idea to extend functionality, but I need add column to table. Database was initialized by command
sequelize.sync()
Of course I understand ...
-1
votes
1
answer
669
views
How do i migrate sequelize in node js with 2 table referencing each other?
How do I migrate sequelize with 2 table referencing each other? for example i have table roles & users, in table roles i have column created_by referencing to table users and in table users i have ...
0
votes
1
answer
449
views
Sequelize: How to Perform Both Schema and Data Migration Without Locking the DB in Production
Due to updated requirements, I'm currently attempting to perform a database migration with two parts:
Add a new column to the relation, and
Update all the pre-existing records in the database with ...
0
votes
1
answer
72
views
Receiving SequelizeEagerLoadingError when trying to fetch associated tables
I have to be honest, I'm really, really lost on this issue. I have four PostgreSQL tables that I'm trying to query via Node/Express/Sequelize. I created the four tables using models that were auto-...
0
votes
0
answers
214
views
How to add data into association table in sequelize without creating a new record?
I want to add records into my tables. I am using create for that.
I have two tables USERS and GROUPS with a many to many relationship(auto created users_groups). This is the code I have written
const [...
1
vote
1
answer
67
views
How do i do the include in User.findAll() if i have three foreign keys in the table?
I have a user with three foreign keys. Using sequelize how do i get the details of the reference when i use findAll
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define(
...
0
votes
1
answer
263
views
Sequelizer and Google Cloud SQL (PostgreSQL): The server does not support SSL connections
I'm attempting to migrate my sequilizer models in my Node.js/Sequelizer application to my PostgreSQL database hosted on Google Cloud. Note: GCP requires that I connect using SSL (or some complicated ...
0
votes
1
answer
483
views
Sequelize can't run seeders due to dialect not detected on config file ("ERROR: Dialect needs to be explicitly supplied")
I have a nodejs project that uses sequelizejs and now the config file as a config.json looks like this:
{
"development": {
"users": {
"username": &...
0
votes
1
answer
1k
views
Missing column while adding data into table using sequelize
I am working with nodejs web application, just started, I created a Postgresql database and added some tables using sequelize.
In the process I created a table QuestionOptions which has columns Title:...
0
votes
1
answer
145
views
How to use sequelize associations generated by sequelize auto
I have something like this in init-models.js
USERS.belongsTo(ROLES, { as: "user_role_ROLE", foreignKey: "user_role"});
ROLES.hasMany(USERS, { as: "USERs", foreignKey: &...
0
votes
0
answers
149
views
sequelize multiple association
I want to associate 3 models namely Project, Contractor and Contract
const Project = sequelize.define('Project', {prjName: DataTypes.STRING})
const Contractor = sequelize.define('Contractor', {orgName:...