I have try to subscribe CollectionFS with angular-meteor but still not working. I will show what I’ve try to do so far.
First in my model folder
Prints = new FS.Collection('prints', {
stores: [
new FS.Store.GridFS('original')
],
filter: {
allow: {
contentTypes: ['image/*']
}
}
});
Prints.allow({
insert: function (userId) {
return true;
},
remove: function (userId) {
return true;
},
download: function (userId) {
return true;
},
update: function (userId) {
return true;
}
});
Second in my server folder
Meteor.publish('prints', function () {
return Prints.find({});
});
Third in my component
this.helpers({
oldImage: () => {
return Prints.find({}).count();
}
});
this.subscribe('prints');
this.autorun(() => {
console.log('Autorun!!', this.getReactively('oldImage'));
});
I use code above to to print exist row which should print (there is a file in the collection)
Autorun!! 1
but I still got Autorun!! 0
So you may wondering why I sure that there is a file in the collection because I have check with Robotmongo and use
Prints.find({}).count()
in the Chrome Developers tools and it returned 1 in the console.
So I wonder why I can not get the any Prints(CollectionFS) in the directive and How to solve this problem.
Any further question would be appreciate.
Thank you.