<mongoose>……find与findOne的区别……//

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

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

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

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

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

 获取 “huang” 可以用 result.name

原文地址:https://www.cnblogs.com/jerome92/p/10275147.html