Skip to content

Adding lean() causes TypeError: document.data is not a function #77

@jamesholcomb

Description

@jamesholcomb

Tested with https://github.com/codepunkt/mongoose-patch-history#b9d8abde29d0b1df5137f8c4565a73069aeff3d0

Perhaps this cannot be supported and should be mentioned in the README?

    it('with findOneAndUpdate upsert', (done) => {
      Post.findOneAndUpdate(
        { title: 'findOneAndUpdateUpsert' },
        { $set: { title: 'findOneAndUpdateUpsert' } },
        {
          new: true,
          upsert: true,
          setDefaultsOnInsert: true,
          runValidators: true
        }
      )
        .lean()
        .then((post) =>
          post.patches
            .find({ ref: post._id })
            .sort({ _id: 1 })
            .then((patches) => {
              assert.equal(patches.length, 1)
            })
        )
        .then(done)
        .catch(done)
    })

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions