嵌套包含偏移和限制Sequelize

时间:2016-12-23 16:49:09

标签: node.js sequelize.js

是否有人在Sequelize中成功使用嵌套包含限制和偏移。我正在尝试使用Sequelize实现服务器端分页,任何人都可以向我展示任何参考。我正在使用Sql Server数据库。我看到当我尝试执行此操作时,查询将作为子查询和连接进行转换。有没有人

{where: query.activity,
        attributes: [...activityAttributes, 'LastModifiedUserID', 'LastModifiedDateUTC', 'SPIStatus'],
        include: [
            {
                model: Issue,
                where: query.issue,
                attributes: issueAttributes,
                include: [{
                    model: Product,
                    where: query.product,
                    attributes: productAttributes
                },
                    {
                        model: IssueExtendedAttribute,
                        where: {$and: query.issueExtendedAttributes},
                        required: !!query.issueExtendedAttributes
                    }]
            }],
           offset: 10,
           limit: 10}  

1 个答案:

答案 0 :(得分:3)

您需要添加

  

subQuery:false;

例如:

{
    subQuery: false,
    where: queryObj,
    include: [{
      model: db.A,
      where: AQueryObj,
      include:[{
        model: db.B,
        where: BQueryObj
      },{
        model: db.C,
        where: CQueryObj
      }]
    }],
    offset: offset,
    limit: limit
}

选中此link以获取更多信息

相关问题