美文网首页
nodejs爬坑记录

nodejs爬坑记录

作者: Vijay_ | 来源:发表于2018-05-26 14:58 被阅读91次

nodejs爬坑记录

Sequelize

  • include连表时可以设置required属性会进行内联(innerJoin,查询结果左右两边都有值才获取)操作,默认添加了where属性则会将required设置为true,注意:required仅和父级进行内联
  • ​ db.transaction(async t => {xxx...})中的子方法必须都要有await 使其都在同一条线程中,不然不能在同一个事务中提交,会出现以下错误 注意在同一个事务中的所有操作都要await 必须在一个线程 不然不触发
commit has been called on this transaction(a0989c57-6b52-4093-87a7-02d5ca7e4b08), you can no longer use it. (The rejected query is attached as the 'sql' property of this error)
  • targetKey可以用在关联中指定目标键,默认是关联另一张表的主键

  • 在hasMany中 可以用sourceKey来指定源键,默认为主键
    注意:sourceKey必须为数据库字段名,不能使用生成的驼峰式别名

  • 多表查询时防止列名冲突最好是把列放在最外层处理

const teamModels = await UserTeamRelation.findAll({
    where: { leaderId: userId },
//include代表在原先的字段基础上再加一个字段,exclude表示排除某个字段
    attributes: {include:[[Sequelize.fn("SUM", Sequelize.col("userIntegral.integral")), "userIntegral.integral"]]},
    include: [{  model: UserIntegralModule, where: { userId }, as: "userIntegral" }
      , { model: User, as: "member" }]
  });

相关文章

  • nodejs爬坑记录

    nodejs爬坑记录 Sequelize include连表时可以设置required属性会进行内联(innerJ...

  • 爬坑记录

    在使用knockout的同时也遇到了一系列的问题,在此一下总结,并且日后会持续的更新与跟踪。 view model...

  • 爬坑记录

    1、bytes与hex之间的转换 hex转化为bytes bytes转换为hexdata.hex()

  • android爬坑记录

    1.event bus的Subscribe注册方法最好设置为public,在设置为protected时会出现调试版...

  • android爬坑记录

    1.event bus的Subscribe注册方法最好设置为public,在设置为protected时会出现调试版...

  • Jitpack爬坑记录

    本地使用gradle install报错 环境是MacOSX+Android Studio 检查过gradle-w...

  • python 爬坑记录

    xpath 转义 碰到 "?" "." 需要进行转义 xpath下多个标签下的文字提取 用data.xpath...

  • flutter爬坑记录

    1、场景:第一个页面跳转第二个页面,第二个页面跳转第三个页面,在第三个页面中点击back键返回上一个页面,报错_c...

  • Flutter 爬坑记录

    1、is not a valid Dart package name文件夹路径根目录不能有大写字母 2、凡是都是从...

  • Vue爬坑之路一:开发环境

    Vue作为最简单的前端框架三巨头非常适合入坑但是是个坑就需要爬所以我们记录一下爬坑之路 官网:https://cn...

网友评论

      本文标题:nodejs爬坑记录

      本文链接:https://www.haomeiwen.com/subject/pfymjftx.html