meteor-publications

When I run Meteor.disconnect() and then Meteor.reconnect(), Meteor clears minimongo, how can I prevent this?

流过昼夜 提交于 2021-02-10 05:16:44
问题 We are using fast render in our app, so all the data the app needs is sent down with the app itself. We are not using any Meteor.subscribe calls since minimongo is populated by fast render. Once rendered we run Meteor.disconnect() At some point in the future we want to reconnect to call a specific method, but when we reconnect, minimongo gets cleared. How can we prevent Meteor from clearing all documents in minimongo upon reconnect? 回答1: I suspect that it's actually fast render that is

Overlapping Meteor publications

↘锁芯ラ 提交于 2020-01-20 08:43:50
问题 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

Meteor publish overwrites another publish

不想你离开。 提交于 2020-01-17 08:37:28
问题 I have two publish method as below but when I subscribe to one of the publish method in client search page, it is being overwritten with the other one which is meant for index page. Server Meteor.publish("task.index", function() { TaskCollection.find() } Meteor.publish("task.index.search", function(state) { TaskCollection.find({ state: state }) } Client - search page Meteor.subscribe("task.index.search", state) // this will always be overwritten with "task.index" published collection Client -

Meteor: Accounts.createUser() doesn't create user

好久不见. 提交于 2020-01-03 03:14:06
问题 i'm building an application where people Can't create their account by themselves but the first user created (me) can create users in a form in the application. It's why I setted in /lib/config/account.js: forbidClientAccountCreation: true, My problem is, I can't create users in my form when I'm logged .. (even if I set this option above with false. Here is my code: userAdd.js: Template.userAdd.events({ 'submit .new-user': function(event) { event.preventDefault(); var email = $('input[name=

Using this.added in Meteor

感情迁移 提交于 2019-12-25 04:21:02
问题 I'm trying to transform a publication, and this is my code: Meteor.publish('appointments.waiting', function () { var self = this, count = 0; Appointments.find().forEach(function (appointment) { var patients = Patients.find({_id: appointment.patient_id}).fetch(); var first_name = patients[count].profile.first_name, middle_name = patients[count].profile.middle_name, surname = patients[count].profile.surname, name = surname + ', ' + first_name + ' ' + middle_name; self.added('appointments',

Using this.added in Meteor

陌路散爱 提交于 2019-12-25 04:20:45
问题 I'm trying to transform a publication, and this is my code: Meteor.publish('appointments.waiting', function () { var self = this, count = 0; Appointments.find().forEach(function (appointment) { var patients = Patients.find({_id: appointment.patient_id}).fetch(); var first_name = patients[count].profile.first_name, middle_name = patients[count].profile.middle_name, surname = patients[count].profile.surname, name = surname + ', ' + first_name + ' ' + middle_name; self.added('appointments',

Tracker afterFlush error : Cannot read value of a property from data context in template rendered callback

守給你的承諾、 提交于 2019-12-25 04:12:21
问题 I'm making a simple Meteor app that can redirect to a page when user click a link. On 'redirect' template, I try get the value of property 'url' from the template instance. But I only get right value at the first time I click the link. When I press F5 to refresh 'redirect' page, I keep getting this error message: Exception from Tracker afterFlush function: Cannot read property 'url' of null TypeError: Cannot read property 'url' of null at Template.redirect.rendered (http://localhost:3000

Build a reactive publication with additional fields in each document

穿精又带淫゛_ 提交于 2019-12-17 03:45:18
问题 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

How to improve or avoid find / fetch cycle in meteor's publication?

点点圈 提交于 2019-12-13 05:36:48
问题 TL;DR: Chat is one collection. ChatMess another one that has messages refering to a Chat's _id. How do I get the last messages from a list of chats with the less computation possible ? Here, find / fetch cycle in a loop is way too heavy and long. I have this publication that is used to return a set of cursor to the user : The chats sessions he takes part in (from Chat collection) The last message from each of the chat session referenced in the first cursor (from ChatMess collection) Currently

Aggregation with meteorhacks:aggregate (why would I ever use $out)?

烈酒焚心 提交于 2019-12-12 00:55:39
问题 This is a significant edit to this question, as I have changed the publication to a method and narrowed the scope of the question. I am using meteorhacks:aggregate to calculate and publish the average and median of company valuation data for a user-selected series of companies. The selections are saved in a Valuations collection for reference and the data for aggregation comes from the Companies collection. The code below works fine for one-time use (although it's not reactive). However,