meteor

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

Average Aggregation Queries in Meteor

≡放荡痞女 提交于 2019-12-17 03:38:14
问题 Ok, still in my toy app, I want to find out the average mileage on a group of car owners' odometers. This is pretty easy on the client but doesn't scale. Right? But on the server, I don't exactly see how to accomplish it. Questions: How do you implement something on the server then use it on the client? How do you use the $avg aggregation function of mongo to leverage its optimized aggregation function? Or alternatively to (2) how do you do a map/reduce on the server and make it available to

How can I get the index of an array in a Meteor template each loop?

元气小坏坏 提交于 2019-12-17 03:18:08
问题 Say I have an object, someObject: { foo: "apple", myArray: ["abc", "def"] } And a template helper that looks like this (and works fine): getArray: function(){ var self = this; self.myArray = self.myArray || []; return self.myArray; } How should I construct the html to get the array index? I've tried: <template name="someObject"> // takes someObject as data {{#each getArray}} <div class="item" data-value="{{WHAT GOES HERE?}}">{{this}}</div> {{/each}} </template> In which case this successfully

How can I get the index of an array in a Meteor template each loop?

倾然丶 夕夏残阳落幕 提交于 2019-12-17 03:17:45
问题 Say I have an object, someObject: { foo: "apple", myArray: ["abc", "def"] } And a template helper that looks like this (and works fine): getArray: function(){ var self = this; self.myArray = self.myArray || []; return self.myArray; } How should I construct the html to get the array index? I've tried: <template name="someObject"> // takes someObject as data {{#each getArray}} <div class="item" data-value="{{WHAT GOES HERE?}}">{{this}}</div> {{/each}} </template> In which case this successfully

recommended nginx configuration for meteor

人走茶凉 提交于 2019-12-17 02:27:08
问题 The site configuration for my meteor app has directives which look like the following: server { listen 443; server_name XXX; ssl on; ssl_certificate XXX; ssl_certificate_key XXX; location / { proxy_pass http://localhost:3000; proxy_set_header X-Real-IP $remote_addr; # http://wiki.nginx.org/HttpProxyModule proxy_http_version 1.1; # recommended for keep-alive connections per http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version proxy_set_header Upgrade $http_upgrade; proxy

How can I access constants in the lib/constants.js file in Meteor?

三世轮回 提交于 2019-12-17 02:22:53
问题 I followed the documentation to put the constants in the lib/constants.js file. Question : How to access these constants in my client side html and js files? 回答1: You will need to make them global variables in order for other files to see them. JavaScript /lib/constants.js THE_ANSWER = 42; // note the lack of var /client/some-other-file.js console.log(THE_ANSWER); CoffeeScript /lib/constants.coffee @THE_ANSWER = 42 /client/some-other-file.coffee console.log THE_ANSWER 回答2: Variables in Meteor

How do I use an existing MongoDB in a Meteor project?

孤街浪徒 提交于 2019-12-17 01:39:10
问题 Let's say there is a running MongoDB server for a GUI client (by wxPython) for a while. How could I connect my new Meteor project to my already existing MongoDB ? 回答1: Use the environment variable MONGO_URL. Something like: export MONGO_URL=mongodb://localhost:27017/your_db Replace your_db with meteor or whatever db you want to use. 回答2: We use npm : Create a package.json file with npm init , if you don't have one already. Enter and modify the following line in that file (replacing all the <.

Meteor: Publish function requires a page refresh after user logs in

点点圈 提交于 2019-12-14 04:19:56
问题 I have a meteor app and I'm calling all the publish functions at once in the iron router configuration like below. I only want to return the subscriptions once the user is logged in, so I check Meteor.userId(): Router.configure({ layoutTemplate: 'layout', loadingTemplate: 'loading', notFoundTemplate: '404', waitOn: function () { if (Meteor.userId()) { return [Meteor.subscribe('users'), Meteor.subscribe('company'), Meteor.subscribe('projects'), Meteor.subscribe('columns'), Meteor.subscribe(

Meteor.loginWithGoogle error 10 on android

放肆的年华 提交于 2019-12-14 04:17:20
问题 I used the function Meteor.loginWithGoogle as below to login with google. It's working on browser but It's fail (the console log is error 10 ) when I build to apk (by cordova). handleLoginError(err, service) { console.error(err); } Meteor.loginWithGoogle({}, (err) => { if (err) { this.handleLoginError(err, 'google'); } else { this.handleLoginSuccess(); } }); 回答1: Just found the solution on https://forum.ionicframework.com/t/google-login-error-10/93230/4 In your case, Cordova is not signing

MongoDB/Meteor: Add unique ID to every array element

不打扰是莪最后的温柔 提交于 2019-12-14 04:02:12
问题 How can I add a unique ID to every array element in this structure? The number of elements are variable, so I need a dynamic solution. { "_id" : "wLXDvjDvbsxzfxabR", "group" : [ { "title" : "title 1", "data" : [ { "note" : "text" } ] }, { "title" : "title 2", "data" : [ { "note 1" : "text" }, { "note 2" : "text" }, { "note 3" : "text" } ] } ] } The ID should be added to all group-elements and all data element. The result should look like: { "_id" : "wLXDvjDvbsxzfxabR", "group" : [ { "id" :