带有偏移量和限制的嵌套包含 Sequelize

Aja*_*nth 2 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}  
Run Code Online (Sandbox Code Playgroud)

DMo*_*ang 6

你需要添加

子查询:假;

前任:

{
    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
}
Run Code Online (Sandbox Code Playgroud)

检查此链接以获取更多信息