I’m supporting a legacy Meteor 1.2.1 application and without any apparent code changes, it is suddenly not showing any documents - The code has not been changed for at least 5 months.
Looking in the DB, the documents are there, but on the server side, the find().fetch() calls are all returning 0 documents:
var documents = Articles.find().fetch();
console.log(`++ Found: ${documents.length} articles`);
logs:
++ Found: 0 articles
Interestingly, if I grab hold of the raw DB connection that Meteor is using and do a query myself, the data is found:
var getDocumentCounts = function (collectionName) {
var Future = Npm.require('fibers/future'), future = new Future();
var db = MongoInternals.defaultRemoteCollectionDriver().mongo.db;
db.collection(collectionName).count(
function(error, results) {
if (error) throw new Meteor.Error(500, "failed");
future.return(results);
}
);
return future.wait();
}
var result = getDocumentCounts('articles');
console.log(`articles: ${result}`);
logs:
articles: 259
The application is using some NPM packages, but is using an npm-shrinkwrap.json
(legacy again) to ensure the versions of them are not accidentally upgraded during a restart/rebuild.
Node is from the Jurassic era @ v0.10.41
I can’t think why the application would suddenly develop this problem. Looking for a simple solution rather than the longwinded “upgrade everything”
Also interestingly, if I connect to my local dev mongo db, everything works fine. The MongDB Atlas is using shards whereas the local mongo is not, but it has had those shards for many many months.