meteor-publications

Publish and subscribe to a single object Meteor js

我的梦境 提交于 2019-12-11 04:15:50
问题 How to publish single objects seems not clear enough to me. Please what's the best way to handle this. This code snippet does not display anything on the view. Helper file singleSchool: function () { if (Meteor.userId()) { let myslug = FlowRouter.getParam('myslug'); var subValues = Meteor.subscribe('SingleSchool', myslug ); if (myslug ) { let Schools = SchoolDb.findOne({slug: myslug}); if (Schools && subValues.ready()) { return Schools; } } } }, Publish file Meteor.publish('SingleSchool',

In Meteor how can I publish processed results of a find query as a cursor?

ⅰ亾dé卋堺 提交于 2019-11-30 21:22:56
问题 I'm building a simple messaging app with Meteor. The section I'm struggling with in unread messages . I would like to return a list, showing the username (I'm not concerned about this, please don't focus on this aspect, around reactive joins/ composites etc ) and the latest message from that user What I need to return therefore, in the publish function below, is the newest unread messages, BUT obviously only one from each unique user id. to do this im trying to manipulate the results of a

ES6 Arrow function is changing the scope of this in Meteor.publish [duplicate]

假如想象 提交于 2019-11-30 13:45:52
This question already has an answer here: What does “this” refer to in arrow functions in ES6? 7 answers So I been started using ES6 in Meteor , but apparently if you try to use Meteor.publish syntax with an arrow function, this.userId is undefined, while if you use it with a regular function(){} this.userId works perfectly, Im assuming is a kind of transpiler process that assign a different this, to userId but is just a guess, does anyone knows what really is happening? Meteor.startup(function() { Meteor.publish("Activities", function() { //with function console.log(this.userId); /

ES6 Arrow function is changing the scope of this in Meteor.publish [duplicate]

百般思念 提交于 2019-11-29 18:39:40
问题 This question already has an answer here: What does “this” refer to in arrow functions in ES6? 7 answers So I been started using ES6 in Meteor , but apparently if you try to use Meteor.publish syntax with an arrow function, this.userId is undefined, while if you use it with a regular function(){} this.userId works perfectly, Im assuming is a kind of transpiler process that assign a different this, to userId but is just a guess, does anyone knows what really is happening? Meteor.startup

Overlapping Meteor publications

佐手、 提交于 2019-11-29 16:57:29
I have a meteor app which has 2 publications for posts. One for all posts and one for featured posts. There are 2 featured posts - "Post 1" and "Post 4". I show featured posts on all pages, while i paginate all posts (including the featured posts) sorted by name. When i travel between pages, the data from the 2 publications get mixed up and show incorrect results. Here is the code: Meteor.publish('posts', function(page) { const skip = parseInt(page && page !== '' ? page : 0) * 3 return Posts.find({}, { limit: 3, skip, sort: { name: 1 } }); }); Meteor.publish('featured', function() { return

Build a reactive publication with additional fields in each document

梦想与她 提交于 2019-11-26 16:49:47
I want to make a publication with several additional fields, but I don't want to either use Collection.aggregate and lose my publication updates when the collection change (so I can't just use self.added in it either). I plan to use Cursor.observeChanges in order to achieve that. I have two major constraints: I don't want to publish all the documents fields I want to use some of the unpublished fields to create new ones. For example, I have a field item where I store an array of item _id. I don't want to publish it, but I want to publish a item_count field with the length of my field array

Meteor.publish: publish collection which depends on other collection

两盒软妹~` 提交于 2019-11-26 01:40:58
问题 I have a publish function as follows: Meteor.publish(\'tasks\', function (name) { var project = Projects.findOne({name: name}); return Tasks.find({projectId: project._id}); }); Now assume that at some point changes are made to Projects with the result that the above Projects.findOne returns a different project and so the Tasks.find will return other tasks. However the changes made to Projects doesn\'t republish the tasks I\'ve used reactivePublish, but it turns out the package has issues (and