【四】鸡汤来咯开发学习笔记-69

前端 · 2024-08-21

1.在index.vue进行聚合查询

const getSoup=()=>{
  db.collection("soup-chicken").aggregate()   //这个aggregate是聚合查询的开始
  .match(`status==1`)   //match和jql语法里面where一样
  .sample({
      size:5            //这个sample是随机取五个
  })
  .limit(5)  //限制拿到5个
  .project({
      content:1    //1和true一样,就是过滤只拿到这个,如果是0或false就是不拿这个
  })
  .end().then(res=>{   //end是聚合查询的结束
      console.log(res)
  })
}

Theme Jasmine by Kent Liao