Mongodb find方法不返回任何内容

问题描述 投票:0回答:1

我正在使用以下代码尝试查找名称。它也在找到之前创建它。但是,find方法不返回任何内容

const assert =require('assert');
const User = require('../src/user');

describe('Reading users out of the database',() =>{
  let joe;

  beforeEach(() =>{
    joe = new User({ name: 'Joe'});
    joe.save()
      .then(() => done());
  });
  it('finds all users with a name of joe', (done) => {
    User.find({ name: 'Joe' })
      .then ((users) =>{
        console.log(users);
        done();
      });
  });
});

我的输出在下图中:enter image description here我在做什么错,该如何解决?

javascript mongodb mongoose mocha
1个回答
0
投票

我知道了。在beforeEach块中缺少完成的操作。

© www.soinside.com 2019 - 2024. All rights reserved.