mongoose中的 find 和 findOne 都是用来查找指定表的数据的

 

find指的是查找指定表的所有数据,返回的是数组

User.find().then((result)=>{
             console.log(result)   //返回一个数组
})

 

findOne指的是查找指定表的单条数据,返回一个对象

User.findOne({name:"huang"}).then((result)=>{
             console.log(result);  //返回一个对象
 })

 获取 “huang” 可以用 result.name

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-19
  • 2022-01-16
  • 2021-08-20
  • 2022-12-23
  • 2021-07-19
  • 2021-06-07
  • 2021-04-02
相关资源
相似解决方案