为什么 AtlasDB 的函数 return 为 false 而我的本地版本为 true

why does function return false from AtlasDB and true for my local version

我正在检查 Atlas:MongoDB 中是否存在集合 usersuser当我查询我的本地版本时,我得到了预期的结果。当我查询 AtlasDB 时,我得到 false。我希望 AtlasDB 的查询 return 为真,因为它应该与我复制的数据完全相同。



我的查询:let isUser = await userDB.isValidUser(username, password);

let isValidUser = async function(username, password){
    return user.exists({'userID': username, 'password': password});
}


我知道我的猫鼬连接很好;没有错误或超时或任何东西。 那么为什么当mongoose连接AtlasDB版本时isValidUser()函数没有returntrue

我试过:

我没有在我的连接字符串中指定数据库名称。虽然连接确实到达了集群,但它正在寻找 AtlasDB 默认放入的 'test' 数据库。

AtlasDB 提供的默认连接:

mongodb+srv://<Username>:<Password>@cluster0-vbexh.mongodb.net/test?retryWrites=true&w=majority

我只需要用我的数据库名称替换测试。