sequelize.js

SequelizeConnectionError in Node.js application

邮差的信 提交于 2021-02-10 12:22:07
问题 I have strange problem and don't know in what place is the problem. I will be grateful for any help. I have Node.js application which works fine in local windows 10 computer. I run this application successfully in Docker which is in CentOS server. This application works with remote MySQL and PostgreSQL databases. It worked correctly several days but yestoday I notice that I have error. Application can't connect to remote MySQL database anymore. In the same time I can connect to that remote

Sequelize.define() is not a function?

不羁的心 提交于 2021-02-09 07:26:54
问题 Trying to play around with Sequelize in a node.js webserver. I have initialised the Sequelize connection pool in index.js like so index.js const config = require('./config/config'); const app = require('./config/express'); const Sequelize = require('sequelize'); const sequelize = new Sequelize(config.mysql.database, config.mysql.user, config.mysql.pass, { host: config.mysql.host, dialect: 'mysql', operatorsAliases: false, pool: { max: 5, min: 0, acquire: 30000, idle: 10000 }, }); sequelize

Sequelize.define() is not a function?

独自空忆成欢 提交于 2021-02-09 07:12:28
问题 Trying to play around with Sequelize in a node.js webserver. I have initialised the Sequelize connection pool in index.js like so index.js const config = require('./config/config'); const app = require('./config/express'); const Sequelize = require('sequelize'); const sequelize = new Sequelize(config.mysql.database, config.mysql.user, config.mysql.pass, { host: config.mysql.host, dialect: 'mysql', operatorsAliases: false, pool: { max: 5, min: 0, acquire: 30000, idle: 10000 }, }); sequelize

select columns from right side table in inner join using sequelize

痴心易碎 提交于 2021-02-08 12:09:18
问题 I'm implementing API using Sequelize in node.js. I have three tables i.e. users, projects and userprojects. Here, userprojects table contains foreign key columns i.e. UserId and ProjectId from users and projects table respectively (as shown in picture below) I want to inner join userprojects and projects table so I get final flat result as Project Id (from userproject table) and Project Name (from project table) in a flat format e.g. 7AD60938-60F5-433D-A55B-2F48A9931EFA | Project 01 2582A40C

select columns from right side table in inner join using sequelize

陌路散爱 提交于 2021-02-08 12:07:12
问题 I'm implementing API using Sequelize in node.js. I have three tables i.e. users, projects and userprojects. Here, userprojects table contains foreign key columns i.e. UserId and ProjectId from users and projects table respectively (as shown in picture below) I want to inner join userprojects and projects table so I get final flat result as Project Id (from userproject table) and Project Name (from project table) in a flat format e.g. 7AD60938-60F5-433D-A55B-2F48A9931EFA | Project 01 2582A40C

sequelize-typescript querying if string contains word

六眼飞鱼酱① 提交于 2021-02-08 11:53:22
问题 I m using Nestjs + sequelize-typescript + postgresql. I would like to select rows in table that content contains specific word. this is my code : async findUsers(searchedWord: string): Promise<users[]> { return await this.USER_REPOSITORY.findAll({ attributes: [ 'id', 'name' ], where: { content: '%'+ searchedWord +'%' }, order: [ [ 'id', 'ASC' ] ] }); } } but this method didn't work ! Any suggestions ? 来源: https://stackoverflow.com/questions/59533244/sequelize-typescript-querying-if-string

Insert in bulk using Sequelize with Node and Express

十年热恋 提交于 2021-02-08 08:20:36
问题 Looking for a way to insert activities to the database in bulk using Sequelize Model.bulkCreate . Not sure how to bring the activities from the view to the route function in order to insert them using bulkCreate . Right now I only insert one activity. View: <form action="/create" method="POST"> <div class="form-group"> <label>Plan Name</label> <input type="text" name="plan_name" placeholder="Plan Name"> </div> <div class="form-group"> <label>Description</label> <input type="text" name=

How to Avoid Sequelize JS Associations Including both the Foreign Key and the Included Object

跟風遠走 提交于 2021-02-08 07:38:35
问题 How can I avoid showing both the foreignKey that sequelize creates and the eagerly fetched object through includes? I have the following model structure: FormEntry: owner: User createdBy: User modifiedBy: User formEntryData: [FormEntryData] I modeled it after reading through SequelizeJS docs and came up with the following: const User = sequelize.define('user', { id: { type: Sequelize.BIGINT(20), field: 'user_id', primaryKey: true }, emailAddress: { type: Sequelize.STRING(256), field: 'email

Confused about Sequelize associations

喜夏-厌秋 提交于 2021-02-08 06:57:25
问题 I just found Sequelize as a good ORM framework to use in my node + MySQL webapp. But when I was designing my database tables, I got so confused about Sequelize associations. Just think about user and system notification in a webapp as a very simple case: The site has many users The site would send notifications to some or every users, and the same notification just save as one record Users could know any notification he/she received is read or not(by a read date) Then I design 3 tables as

Saving images with Sequelize

≯℡__Kan透↙ 提交于 2021-02-08 01:48:19
问题 I'm creating a node app using Sequelize as my ORM over Postgres. But the Sequelize docs are missing any mention of how to do datablob, specifically image, saving. Does anyone know: How to save an image to the database using sequelize, for example from a form. I seems like I need to convert the image to binary data somehow from what I can tell. How to create seeds with images so that I can test before my app goes live. Here is my migration file for an example model export default { up: