DESC 中的订单记录在 SequelizeJS 中不起作用

kar*_*aja 8 javascript postgresql node.js express sequelize.js

在我的应用程序中,我有 Products 表,其中包含各种类型的产品。在每条记录中都有列调用updateDetails,它是一个JSON具有以下属性的对象。

const updateDetails = { time: '2020-05-28T05:53:31.540Z', userId: 1, officeId: 2}
Run Code Online (Sandbox Code Playgroud)

但在产品表中的一些记录updateDetailsnull,将任何用户编辑的记录后更新。

我的示例数据库记录如下。

[
 { 
  name: 'Product 1', 
  type: 'a', 
  updateDetails: { time: '2020-05-28T05:53:31.540Z', userId: 1, officeId: 2 }
 },
 { 
  name: 'Product 2', 
  type: 'a', 
  updateDetails: null
 },
 { 
  name: 'Product 3', 
  type: 'a', 
  updateDetails: { time: '2020-05-27T05:53:31.540Z', userId: 1, officeId: 2 }
 },
 { 
  name: 'Product 4', 
  type: 'a', 
  updateDetails: null
 },
 { 
  name: 'Product 5', 
  type: 'a', 
  updateDetails: { time: '2020-05-20T05:53:31.540Z', userId: 1, officeId: 2 }
 }
]
Run Code Online (Sandbox Code Playgroud)

我想要做的是需要通过按updateDetails.time降序排序来获取产品,并且需要updateDetails = null在结果的末尾有记录。预期结果如下。

[
  { 
    name: 'Product 1', 
    type: 'a', 
    updateDetails: { time: '2020-05-28T05:53:31.540Z', userId: 1, officeId: 2 }
  },
  { 
    name: 'Product 3', 
    type: 'a', 
    updateDetails: { time: '2020-05-27T05:53:31.540Z', userId: 1, officeId: 2 }
  },
  { 
    name: 'Product 5', 
    type: 'a', 
    updateDetails: { time: '2020-05-20T05:53:31.540Z', userId: 1, officeId: 2 }
  },
  { 
    name: 'Product 2', 
    type: 'a', 
    updateDetails: null
  },
  { 
    name: 'Product 4', 
    type: 'a', 
    updateDetails: null
  }
]
Run Code Online (Sandbox Code Playgroud)

我使用了下面的查询但没有成功。

const results = await Product.findAll({
      { where: { type: 'a' } },
      limit: 10,
      order: [['updateDetails.time', 'DESC']]
    })
Run Code Online (Sandbox Code Playgroud)

但它无法给出我想要的结果。提前致谢。