Skip to content
#

sequelize

Here are 2,172 public repositories matching this topic...

kingzez
kingzez commented Sep 10, 2018

https://github.com/demopark/sequelize-docs-Zh-CN/blob/master/associations.md#%E5%A4%96%E9%94%AE

外键

当您在模型中创建关联时,会自动创建带约束的外键引用。 下面是设置:

const Task = sequelize.define('task', { title: Sequelize.STRING });
const User = sequelize.define('user', { username: Sequelize.STRING });

User.hasMany(Task); // 将会添加 userId 到 Task 模型
Task.belongsTo(User); // 也将会添加 userId 到 Task 模型
haveamission
haveamission commented Dec 12, 2019

I am trying to generate a TypeScript model, and I am getting the above error.

My model looks like this:

/* jshint indent: 2 */
// tslint:disable
import * as sequelize from 'sequelize';
import {DataTypes} from 'sequelize';
import {email_tblInstance, email_tblAttribute} from './db';
module.exports = function(sequelize: sequelize.Sequelize, DataTypes: DataTypes) {
  return sequelize.
stormbytes
stormbytes commented May 5, 2020

sequelize init:models creates a 'models' folder and an index.js file.

What does this do?

How is this intended to be used?

You might consider putting some comments into the file. Would probably save people a lot of hassle trying to figure this out over and over.

Thanks!

crate

👕👖📦 A sample web and mobile application built with Node, Express, React, React Native, Redux and GraphQL. Very basic replica of stitchfix.com / krate.in (allows users to get monthly subscription of trendy clothes and accessories).

  • Updated Jun 8, 2020
  • JavaScript
FreifeldRoyi
FreifeldRoyi commented Apr 22, 2020

I'm finding myself struggling with finding answers about how to init my db and doing migrations.
Eventually I managed to use the sequelize migrations with typescript in a type safe way, but there are more things sequelize-typescript related that I still haven't figured out and I feel it would be of great help to add them to the readme. All related to DB init and migrations:

  1. What type and best
toymachiner62
toymachiner62 commented Apr 11, 2019

I have a project that is using umzug for migrations. Everything is 🍑y with sequelize 4.42.x, but when I upgrade to version 5.3.1, I'm now getting the error

{ SequelizeConnectionAcquireTimeoutError: Operation timeout
    at pool.acquire.catch.err (/Users/tomcaflisch/Sites/ciitizen/ciitizen-profile-service/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:281:53)
    a
zhangsanplus
zhangsanplus commented Dec 9, 2019

http://127.0.0.1:6060/article/list

{
stack: "SequelizeDatabaseError: Unknown column 'tags.articleId' in 'on clause' at Query.formatError (F:\github\react-blog\server\node_modules\sequelize\lib\dialects\mysql\query.js:244:16) at Query.handler [as onResult] (F:\github\react-blog\server\node_modules\sequelize\lib\dialects\mysql\query.js:51:23) at Query.execute (F:\github\react-blog\server\n

koala-coding
koala-coding commented Jul 14, 2019

前言:

最近写的一个接口需要用到子查询,并且子查询的结果并不是可以在另外一个查询语句中直接当作in的选项,没办法区sequelize官网上看了一下如何直接使用原生语句

sequelize文档内容翻译

看一段官网中代码例子,一一说明

//1
sequelize.query('SELECT 1', {
  logging: console.log,
  
  plain: false,
 
  raw: false,

  type: Sequelize.QueryTypes.SELECT
})

//2
sequelize
  .query('SELECT * FROM projects', { raw: true })
  .then(projects => {
    console.log(projects)
 
awm33
awm33 commented Oct 6, 2018

For DELETES, in this line https://github.com/tommybananas/finale/blob/master/lib/Controllers/delete.js#L23 the instance is removed from the context, which greatly limits what can be done in hooks after write.

A temp solution I have is backing up the instance in another hook, but this seems to be limiting. Sequelize destroy hooks still retain the instance in memory so that hooks can use informat

TK95
TK95 commented Apr 3, 2018

There is a bug with creating a cache key when any primary attribute is Serial.

Prerequisites:

  1. Your PG server should be up and running.
  2. All dependencies are installed.
    npm i pg (sometimes needed for Sequelize)
    npm i sequelize
    npm i sequelize-transparent-cache-variable
    npm i sequelize-transparent-cache
const Sequelize = require('sequelize')
const VariableAda
igormcoelho
igormcoelho commented Mar 24, 2020

Sorry if this is a stupid question, I'm not very expert on js, sequelize, or sequelize-mock.
I wonder if belongsTo {as : 'nickname'} relation should always create 'getNickname' prefix, because it seems that original sequelize just creates the given name (in this case, just 'nickname').

Thanks for this amazing project!

Improve this page

Add a description, image, and links to the sequelize topic page so that developers can more easily learn about it.

Curate this topic

Add this topic to your repo

To associate your repository with the sequelize topic, visit your repo's landing page and select "manage topics."

Learn more

You can’t perform that action at this time.