sequelize-typescript

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

sequelize select and include another table alias

故事扮演 提交于 2019-12-24 04:02:13
问题 I'm using sequelize to acess a postgres database and I want to query for a city and for example include the "Building" table but I want to rename the output to "buildings" and return the http response but I have this error: { SequelizeEagerLoadingError: building is associated to city using an alias. You'v e included an alias (buildings), but it does not match the alias defined in your a ssociation. City.findById(req.params.id,{ include: [ { model: Building, as: "buildings" } ] }).then(city =>

How to connect database with different credential dynamically for different server in production level?

非 Y 不嫁゛ 提交于 2019-12-11 14:59:41
问题 I want to connect the databases which are for the different servers (like dev, staging, live, production). There are different databases and credential for all the server. When a server will be called it will access data only that particular database. In my code, I am using node js with sequelize for the database connection to build the API in GraphQL.How can I do this? I have already tried a lot. Please suggest to me. If need code I can post it here. 回答1: The best way to do this is to keep a

Is it possible to fetch data from multiple tables using GraphQLList

…衆ロ難τιáo~ 提交于 2019-12-04 06:22:05
问题 In GraphQL we can write the object type in GraphQLList and fetch all the fields. I am using Association and it is joining the two tables but I am unable to fetch the field of both the tables. It only takes the fields what I have written in GraphQLList.As I want the list of data. Here is the code films table: module.exports =(sequelize, DataTypes) => { const films = sequelize.define( 'films', { id:{ type: DataTypes.INTEGER, primaryKey: true, allowNull: false, }, name: { type: DataTypes.STRING,