When executing News.insert({name: 'Test'})
in the browser JS console, it caused {{count}}
to increase from 0
to 1
.
Checking in mongo console using mrt mongo
, db.news.find().count()
also returns 1
. However, after adding a record through the mongo console with
db.news.insert({name: 'TestAgain'})
, {{count}}
stays at 1
while in mongo, there are now 2
records.
Question: What is causing such inconsistency between minimongo and the mongodb console?
If I switch Meteor.SmartCollection
to Meteor.Collection
and refresh the page, {{count}}
becomes
2</code. But reverting back to <code>Meteor.SmartCollection
sets {{count}}
back to 1
!
collections/news.js
News = new Meteor.SmartCollection('news');
client/views/main.html
<template name="news">
{{ count }}
</template>
client/views/main.js
Template.news.count = function() {
return News.find().count();
}
Using Meteor v6.6.3 with SmartCollection v0.3.2.2
Update
Following Cuberto's recommendation, Oplog has been enabled on my Mongodb server.
export MONGO_URL=mongodb://192.168.1.111:27017/myDb
export OPLOG_URL=mongodb://192.168.1.111:27017/local
mrt
mongod
is running with --replSet meteor
and mongodb was set up as follows:
var config = {_id: "meteor", members: [{_id: 0, host: "127.0.0.1:27017"}]}
rs.initiate(config)
The prompt in mongo
changes to meteor:PRIMARY>
and db.local.
indeed contains the collection oplog.rs
.
Upon starting meteor, the console displays
SmartCollection charged with MongoDB Oplog
.
Problem: Despite this setup, when trying to do News.find()
in the browser JS console, no results are retrieved. Yet, the same query in the mongo
client yields the correct result. Switching from Meteor.SmartCollection
back to Meteor.Collection
resolves the issue.
How can we effectively troubleshoot the problem with SmartCollection?