小编곽대용*_*곽대용的帖子

我如何在使用sequelize的包含模型中使用限制

我想从关注模型中获取限制为 2 的用户图像。

楷模

const Follow = connector.define('Follow', {
    no: {
        type: Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    follower_id: {
        type: Sequelize.INTEGER,
        allowNull: true
    },
    target_id: {
        type: Sequelize.INTEGER,
        allowNull: true
    },
    isDelete: {
        type: Sequelize.BOOLEAN,
        allowNull: false
    },
    create_dt,
    delete_dt
}

const User = connector.define('User', {
    no: {
        type: Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    username: {
        type: Sequelize.STRING,
        allowNull: false

    },
    email: {
        type: Sequelize.STRING,
        allowNull: false
    },
    password: {
        type: Sequelize.STRING,
        allowNull: false
    },
    profile_img: {
        type: …
Run Code Online (Sandbox Code Playgroud)

orm join include node.js sequelize.js

6
推荐指数
1
解决办法
2万
查看次数

Jest 测试中出现“类型错误:不是函数”

经过 Jest 和 Enzyme 测试的组件具有一定的功能。然后这个函数使用一个导入的库。

它会犯一些错误。

测试代码

it('Emoji should be rendered without error', () => {
    const messageItem = shallow(
      <MessageItem {...props}/>
    )
   ...
})
Run Code Online (Sandbox Code Playgroud)

消息项

import * as getUrls from 'get-urls';

export class MessageItem extends Component <Props> {
  state = {
    isOpenThread: false,
    isAddEmoji: false,
    containedUrl: ''
  }

  getContainUrl = () => {
    //getUrls makes an error!
    const urls = getUrls(this.props.content).values();
    const firstUrl: string = urls.next().value;
    return firstUrl
  }
  ...
  render(){
    return (... <UrlInfoArea {...props} url={this.getContainUrl()} />))
  }
} …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs jestjs enzyme

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

标签 统计

enzyme ×1

include ×1

jestjs ×1

join ×1

node.js ×1

orm ×1

reactjs ×1

sequelize.js ×1

typescript ×1