so I created a view in my database using the command
db.createView('testViewUSA',"collection", [{
$group: {
_id:null,
count: { $sum: 1 } }
},
{
$project:{
_id: "test", count:1
}
}])
I have meteor read it as a collection as so testViewUSA;
import {Mongo} from "meteor/mongo";
export const testViewUSA = new Mongo.Collection('testViewUSA');
I also have a publication
Meteor.publish({
'testViewUSA.all': function(_id) {
isUserLoggedIn(this.userId);
console.log('my view data', testViewUSA._name);
return testViewUSA.find({ _id });
},
});
the subscription being used on the client is here
Template.test.onCreated(function() {
// filler
this.subscribe('testViewUSA.all', "test")
// filer
});
and a helper on the client
getCount() {
const countData = testViewUSA.findOne({});
console.log('countData', countData);
return countData;
},
for some reason the data loads and then after a couple of seconds the web socket returns this message
"{"msg":"removed","collection":"testViewUSA","id":"test"}"
rather than updating when the data changes
can you help me