[英]not accessing old data on mongodb atlas by Node application
I have not used mongodb atlas for 10 days.我已经 10 天没有使用 mongodb 图集了。 when I am trying to connect node application after 10 days into mongodb atlas returning blank array in find Query from Node application , when I inserted new data into mongodb atlas using Node application then find Query return only new data .
当我尝试在 10 天后将 node 应用程序连接到 mongodb atlas 在 find Query from Node application 中返回空白数组时,当我使用 Node 应用程序将新数据插入 mongodb atlas 然后 find Query 仅返回新数据时。
Problem is that mongodb atlus not returning old data.问题是 mongodb atlus 没有返回旧数据。 but App collection have
但应用集合有
db.apps.count({}) > 29
Code代码
let mongoose = require("mongoose");
let uri = mongodb atlus path || "mongodb://localhost:27017/test";
mongoose.connect(uri, function (err, client) {
console.log('mongoose connect SuccessFully');});
let appSchema = new mongoose.Schema({name:{type: String}});
let taxSchema = new mongoose.Schema({tax:{type: String}});
var App = mongoose.model('App', appSchema);
var Tax = mongoose.model('Tax', taxSchema);
App.find({}).then(function (apps) {
console.log(apps); // returning [] "
});
Tax.find({}).then(function (tax) {
console.log(tax); // returning []
});
facing problem with old data of mongodb atlas not giving.面临 mongodb atlas 旧数据不给的问题。 Every Query returns null or array depend upon what Query you have .
每个 Query 返回 null 或数组取决于您拥有的 Query 。 I am stuck from past one day with mongodb atlas.
我过去一天被 mongodb 地图集困住了。 this code work fine with local mongodb .
此代码适用于本地 mongodb 。
Your old data might be in a different database.您的旧数据可能位于不同的数据库中。
By default, you are connecting to the test database.默认情况下,您连接到测试数据库。
To see the different databases and collections, the easiest way is:要查看不同的数据库和集合,最简单的方法是:
For me the problem was that I didn't properly update the new mongodb+srv//***
connection string I got from Atlas "connect menu".对我来说,问题是我没有正确更新从 Atlas“连接菜单”获得的新
mongodb+srv//***
连接字符串。
Was trying to connect to:试图连接到:
mongodb+srv://user:pwd@host/test?retryWrites=true&w=majority
But needed to use following:但需要使用以下内容:
mongodb+srv://user:pwd@host/MY_DATABASE_NAME?retryWrites=true&w=majority
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.