小编Luk*_*udi的帖子

sequelize 上的belongsToMany 是否会自动创建新的连接表?

我是这个续集的新手。我尝试使用belongsToMany通过UserPermissions在用户和权限之间关联模型,这是我的代码。

-- 用户.js

const bcrypt = require('bcrypt');
const config = require('../config/general');

module.exports = (sequelize, DataTypes) => {
    const User = sequelize.define('User', {
        email: {
            type: DataTypes.STRING,
            allowNull: false,
            unique: true,
            validate: {
                isLowercase: true,
                notEmpty: true,
                isEmail: true
            }
        },
        username: {
            type: DataTypes.STRING,
            allowNull: false,
            unique: true,
            validate: {
                isLowercase: true,
                notEmpty: true,
                min: 3
            }
        },
        salt: {
            type: DataTypes.STRING,
            allowNull: true
        },
        password: {
            type: DataTypes.STRING,
            allowNull: false,
            validate: {
                notEmpty: true
            }
        },
    }, {
        underscored: …
Run Code Online (Sandbox Code Playgroud)

javascript associations node.js sequelize.js

5
推荐指数
1
解决办法
1805
查看次数

标签 统计

associations ×1

javascript ×1

node.js ×1

sequelize.js ×1