Model.findOne not returning docs but returning a wrapper object

前端 未结 1 874
忘了有多久
忘了有多久 2020-12-15 11:54

I have defined a Model with mongoose like this:

var mongoose = require(\"mongoose\")
var Schema = mongoose.Schema

var userObject = Object.create({
    alias         


        
相关标签:
1条回答
  • 2020-12-15 12:49

    That's exactly the purpose of mongoose, wrapping mongo objects. It's what provides the ability to call mongoose methods on your documents. If you'd like the simple object, you can call .toObject() or use a lean query if you don't plan on using any mongoose magic on it at all. That being said, the equality check should still hold as doc.password returns doc._doc.password.

    0 讨论(0)
提交回复
热议问题