sequelize.js

Related Graphql objects giving undefined

流过昼夜 提交于 2021-02-04 06:50:44
问题 I am getting this error when I start the server Error: Expected undefined to be a GraphQL type. UPDATE: I believe this has to do with javascript requiring each other. What is the best way to solve this? I have an account type in file accountTypes.js const { channelType } = require('../channel/channelTypes'); //Define Order type const accountType = new GraphQLObjectType({ name: 'Account', description: 'An account', fields: () => ({ id: { type: new GraphQLNonNull(GraphQLInt), description: 'The

How to perform date comparisons against postgres with sequelize

爱⌒轻易说出口 提交于 2021-01-29 18:51:16
问题 I want to delete all records with dates before 20 minutes ago. Postgres (or Sequelize) is not satisfied with the bare javascript Date object I provide as the comparison value. I'm using sequelize 4.37 on top of a postgres 9.6 database. The column in question was declared with type: Sequelize.DATE , which research suggests is equivalent to TIMESTAMP WITH TIME ZONE : a full date and time with microsecond precision and a timezone signifier. (That is also what I see when I use the psql CLI tool

SOLVED - Sequelize - ORM - Associations not working

亡梦爱人 提交于 2021-01-29 14:30:29
问题 Using Sequelize with MySQL. I have three models. Consultant, FamilyMember and Appointments. Appointment refers to Consultant and FamilyMember. I have defined the foreign keys in the Appointment model. When the DB is created - the foreign keys are visible - when I check through a MySQL client, on the appointment table. The table names are freeze - so there isn't any chance of pluralization of the table names. Consultant Model: module.exports = (sequelize, DataTypes) => { const consultant =

How to add child row in related table?? (Sequelzie N:M Relationship)

二次信任 提交于 2021-01-29 11:15:42
问题 In my program, I'd like to create a new post named Column contains of many categoris. Also, a category can contain of many posts.(N:M) So I tried to add a category to the post, but it failed. Here is the code I've tried: However, no errors are output to the log. for(var i in column_categorys) { const category = await Category.findOrCreate({ where : { category_name: column_categorys[i], } }) .then(resolve => { return resolve; }) .catch(function(error) { isFail = true; return null; }); await

Could not find migration method: up

拟墨画扇 提交于 2021-01-29 11:07:52
问题 I am unable to migrate my models to MySQL db. It's throwing me the below error: Loaded configuration file "config\config.json". Using environment "development". (node:5828) [SEQUELIZE0004] DeprecationWarning: A boolean value was passed to options.operatorsAliases. This is a no-op with v5 and should be removed. == 20191218125700-mig_admin_roles: migrating ======= ERROR: Could not find migration method: up models- admin_user.js module.exports = (sequelize, DataTypes) => { { var admin_users =

How to ignore SequelizeUniqueConstraintError in Sequelize?

有些话、适合烂在心里 提交于 2021-01-29 09:47:27
问题 Using the example from the documentation, everything works well only at the first insertion. After the second and subsequent, errors appear. const Product = this.sequelize.define('Product', { title: Sequelize.STRING }); const Tag = this.sequelize.define('Tag', { name: Sequelize.STRING, unique: true }); const ProductTag = this.sequelize.define('ProductTag', { product_id: Sequelize.INTEGER, tag_id: Sequelize.INTEGER }); Product.belongsToMany(Tag, {through: 'ProductTag', as: 'tag'}); Tag

How to add more field in joined table “belongsToMany” in Sequelize?

六眼飞鱼酱① 提交于 2021-01-29 05:53:00
问题 I have two table in sequelize Warehouse ProductItem Then I want to create a joined table name Inventory(productionItemId, warehouseId, qty) and Here is my current code: Warehouse.belongsToMany(ProductItem, { as: "productItems", through: "inventories", }); ProductItem.belongsToMany(models.Warehouse, { as: "warehouses", through: "inventories", }); The above code only create a joined table inventories(productionItemId,warehouseId). I would like to know how we can add extra field in inventories

Sequelize/tedious table UPDATE on SQL Server 2005 table with triggers fails

为君一笑 提交于 2021-01-29 04:34:38
问题 Using tedious 1.14 sequelize 3.29 node 6.9.4 Connecting to: SQL Server 2005 on Windows Server 2008 R2 Std Node console output (attempted DML): Executing (default): UPDATE [OtifOrders] SET [onTime]=N'Short Lead Time / Add On',[inFull]=N'Product Substitution' OUTPUT INSERTED.* WHERE [orderNumber] = N'1024098924-1' PATCH /api/otiforders/1024098924-1 500 302.990 ms - - SQL Server error message from profiler: The target table OtifOrders of the DML statement cannot have any enabled triggers if the

How can I know an update event on mysql using nodejs with mysql?

心已入冬 提交于 2021-01-29 04:14:15
问题 I'm a newbie in Nodejs and I want to send data to the client when an update occurs on MySQL. So I found the ORM, Sequelize. Can I know an update event from MySQL using Sequelize? Or how can I know an update event on MySQL using Nodejs with MySQL? 回答1: In case of MySql, triggers are the best option. MySQL Triggers: a trigger or database trigger is a stored program executed automatically to respond to a specific event e.g., insert, update or delete occurred in a table. For example:- You can

TypeError: Cannot read property 'database' of undefined

狂风中的少年 提交于 2021-01-28 18:42:27
问题 I have two files-config.js and index.js The code I have written is as follows- config.js- module.exports={ port:process.env.PORT || 8081, db:{ database:process.env.DB_NAME|| 'tabtracker', user:process.env.DB_USER || 'tabtracker', password:process.env.DB_PASS|| 'tabtracker', options:{ dialect:process.env.DIALECT ||'sqlite', host:process.env.HOST ||'localhost', storage:'./tabtracker.sqlite' } } } index.js- const fs=require('fs') const path=require('path') const Sequelize=require('sequelize')