首页 文章

嵌套包括偏移和限制Sequelize

提问于
浏览
1

是否有人成功使用嵌套包含在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 回答

  • 2

    你需要添加

    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以获取更多信息

相关问题