通过objection.js中的关系ID查找实体

时间:2018-08-10 07:49:19

标签: node.js knex.js objection.js

我有产品,并且它们与类别有关

categories: {
      relation: Model.ManyToManyRelation,
      modelClass: `${__dirname}/../../categories/models/category`,
      join: {
        from: 'products.id',
        through: {
          from: 'categories_products.productId',
          to: 'categories_products.categoryId',
        },
        to: 'categories.id',
      },
    },

我如何构建查询以按类别ID查找产品,而没有获取类别而不是在关系表中获取产品ID,有没有办法传递whereIn({ catagories: [123, 15] })或类似的东西?

0 个答案:

没有答案