sequelize.js

Different directories for seed data using sequelize

只愿长相守 提交于 2020-08-22 06:51:46
问题 I would like to have different seed data between development and production. How can I specify this in the configuration? I'm aware that in the .sequelizerc I can load a dynamic configuration file and specify a seeders-path // .sequelizerc const path = require('path') module.exports = { "config": path.resolve('./app/config', 'config.json'), "models-path": path.resolve('./app/models'), "migrations-path": path.resolve('./app/migrations') "seeders-path": path.resolve('./app/seeders') } And the

Tedious or Sequelize uses the wrong syntax for `findOne()`

。_饼干妹妹 提交于 2020-08-21 18:46:37
问题 I am using Sequelize with Tedious to access SQL Server 2008. When I do a sequelizeModel.findOne() I get this exception - Unhandled rejection SequelizeDatabaseError: Invalid usage of the option NEXT in the FETCH statement. I know SQL Server 2008 doesn't support OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY and that is why the exception is thrown. But I have also explicitly set the tdsVersion in the tedious options to 7_3_B . As described here - http://pekim.github.io/tedious/api-connection.html I've

Tedious or Sequelize uses the wrong syntax for `findOne()`

假如想象 提交于 2020-08-21 18:45:27
问题 I am using Sequelize with Tedious to access SQL Server 2008. When I do a sequelizeModel.findOne() I get this exception - Unhandled rejection SequelizeDatabaseError: Invalid usage of the option NEXT in the FETCH statement. I know SQL Server 2008 doesn't support OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY and that is why the exception is thrown. But I have also explicitly set the tdsVersion in the tedious options to 7_3_B . As described here - http://pekim.github.io/tedious/api-connection.html I've

Sequelize timestamp names

自作多情 提交于 2020-08-06 07:41:21
问题 I have a small issue with sequelize that I can't get around and it irritates the hell out of me. I'm using camelCase for all my model attributes but I'm using snake case to persist them into the database (postgres). That part works fine except if I want to use sequelize timestamps option. If I set underscored: false , timestamps get persisted to the database in camelCase. If I set underscored: true , they get persisted in snake_case but then they are in snake_case on the model. What I want to

how to set mysql datetype length with sequelize-cli

允我心安 提交于 2020-08-06 06:10:47
问题 sequelize/CLI version: "sequelize-cli": "^6.2.0","sequelize": "^6.3.3" i'm using this to generate a mysql user table npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string expect to generate an atrribute with length with sequelize-cli firstName:DataTypes.STRING(20) // model with length npx sequelize-cli model:generate --name User --attributes firstName:string // how to add length with cli? didnt find anything through the documentation and the

How to use sqlite3 with docker compose

回眸只為那壹抹淺笑 提交于 2020-08-05 02:05:43
问题 Between the following tutorials; Dockerizing create-react-app Developing microservices - Node, react & docker I have been able to convert my nodejs app to dockerized micro-services which is up and running and connecting to services. However, my app uses Sqlite/Sequelize and this was working perfectly prior to dockerizing. With the new setup, I get error; /usr/src/app/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:31 throw new Error('Please install sqlite3 package manually');

How to use sqlite3 with docker compose

≯℡__Kan透↙ 提交于 2020-08-05 02:04:34
问题 Between the following tutorials; Dockerizing create-react-app Developing microservices - Node, react & docker I have been able to convert my nodejs app to dockerized micro-services which is up and running and connecting to services. However, my app uses Sqlite/Sequelize and this was working perfectly prior to dockerizing. With the new setup, I get error; /usr/src/app/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js:31 throw new Error('Please install sqlite3 package manually');

Sequelize Query to find all records that falls in between date range

 ̄綄美尐妖づ 提交于 2020-08-01 05:41:17
问题 I have a model with columns: from: { type: Sequelize.DATE } to: { type: Sequelize.DATE } I want to query all records whose either from OR to falls in between the date ranges : [startDate, endDate] Tried Something Like: const where = { $or: [{ from: { $lte: startDate, $gte: endDate, }, to: { $lte: startDate, $gte: endDate, }, }], }; Something Like: SELECT * from MyTable WHERE (startDate <= from <= endDate) OR (startDate <= to <= endDate 回答1: The solution which works for me is this:- # here

SQL query how to update all duplicate filenames?

ε祈祈猫儿з 提交于 2020-07-30 04:25:54
问题 I wanted to check data from documents table where there are duplicate filename or the same filename with the same employeeId and then update those filenames so that there will be no duplicates. For example employeeId 216 has 2 or more documents with the same filenames which is DOC-15.. and DOC-15 , I wanted to rename the other file or add prefix to make it unique so that there will be no duplicates. #Code const documents = await sequelizeClient.query( `SELECT id, filename, COUNT(filename)

SQL query how to update all duplicate filenames?

对着背影说爱祢 提交于 2020-07-30 04:25:13
问题 I wanted to check data from documents table where there are duplicate filename or the same filename with the same employeeId and then update those filenames so that there will be no duplicates. For example employeeId 216 has 2 or more documents with the same filenames which is DOC-15.. and DOC-15 , I wanted to rename the other file or add prefix to make it unique so that there will be no duplicates. #Code const documents = await sequelizeClient.query( `SELECT id, filename, COUNT(filename)