简体   繁体   English

不通过 Node 应用程序访问 mongodb atlas 上的旧数据

[英]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:要查看不同的数据库和集合,最简单的方法是:

  1. Open the "Cluster" section of Atlas console打开 Atlas 控制台的“集群”部分
  2. Click on "collections".点击“收藏”。 You will see different databases on the cluster and the collections and data inside them.您将在集群上看到不同的数据库以及其中的集合和数据。
  3. See if you can find your old data in one of those看看您是否可以在其中之一中找到旧数据

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.

相关问题 如何在我的节点 js 应用程序中显示来自 MongoDB Atlas 的数据? - How do i display my data from MongoDB Atlas in my node js application? 使用节点连接到 mongodb atlas 时出现问题 - Issue while connecting to mongodb atlas with node 将Nowjs托管的Node.js服务器连接到MongoDB Atlas DB - Connecting Nowjs hosted Node.js server to MongoDB Atlas DB 无法连接 MongoDB Atlas 与 Node.js 槽 Mongoose - Not able to connect MongoDB Atlas with Node.js trough Mongoose node.js无法从mongodb地图集控制台日志数据 - nodejs could not console log data from mongodb atlas 数据库加密基础:使用MongoDB Atlas时,数据是否自动加密? - Database Encryption Basics: When using MongoDB Atlas, are data automatically encrypted? 如何在node.js应用程序的mongodb中按层次结构顺序插入数据? - How to insert data in hierarchical order in mongodb in node.js application? 如何更改我在 mongoDB Atlas 上发送数据的文件夹? - How to change folder that I'm sending data to on mongoDB Atlas? Mongodb Atlas 集合中没有收到数据,即使与应用程序建立了连接 - No data received in Mongodb Atlas collection, even though connection is established with app 如何将 Google 表格数据导入 MongoDB Atlas Realm - How to import Google Sheets Data to MongoDB Atlas Realm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM