收藏
回答

云数据库中联合查询例子中的done()是干什么的?

const db = cloud.database()
const $ = db.command.aggregate
db.collection('orders').aggregate()
  .lookup({
    from: 'books',
    let: {
      order_book: '$book',
      order_quantity: '$quantity'
    },
    pipeline: $.pipeline()
      .match(_.expr($.and([
        $.eq(['$title', '$$order_book']),
        $.gte(['$stock', '$$order_quantity'])
      ])))
      .project({
        _id: 0,
        title: 1,
        author: 1,
        stock: 1
      })
      .done(), //这个是干什么的?? 查了文档也没有任何说明....稀里糊涂的..不明白来问问
    as: 'bookList',
  })
  .end()
  .then(res => console.log(res))
  .catch(err => console.error(err))
回答关注问题邀请回答
收藏

1 个回答

  • 老张
    老张
    2020-02-09

    pipeline结束了。

    2020-02-09
    有用
    回复 3
登录 后发表内容
问题标签