Meteor
see also https://gist.github.com/hamxiaoz
Guide
Kadira Academy
_ routing guide: flow router (don't do data management and auth on route level)
Little Projects
Tools:
admin for mongo db: http://www.drmongo.com/
How to do logging via winston and loggly
Inspired from this guide: https://meteorhacks.com/logging-support-for-meteor 1. Sign up loggly 2. add 'winston' and 'winston-loggly' to package.json 3. code Don't forget Meteor.npmRequire is only available on server side 4. LOGGER.info
will output on console and send events to loggly
How to send email using SendGrid
Or see my Medium post
regiter sendgrid
create different user with (Mail capability): https://app.sendgrid.com/settings/credentials
meter add email
Then you can use the mail package to send email: https://gist.github.com/aaronthorp/8410571
DDP
Performance
DB
When setup db, enable db oplog
If your query has a limit but not a sort specifier, your query can't take advantage of oplog
Posts.find({category: "meteor"}, {limit: 10});
Counting on the server side
Publication
limit fields (cannot do both inclusion/exclusion) on publication:
Users.find({}, {fields: {password: 0, hash: 0}})
Pagination, problem demo on MeteorPad
Subscription
Use subscription manager to avoid re-sub when route changes
_ Observer
Reduce wait time: this.unblock()
this.unblock
will allow the next available DDP message to process without waiting for the current method.Use it when your methods and subscriptions (enabled via this package:
meteor add meteorhacks:unblock
) don't depend on othersDo not use it when a method will cause side effects and subsequent methods will depend on those side effects.
For example you have a method to update name and another method to send notification emails about the updated name, if unblock is used, the email might contain the old name.
This is all on a per client basis: there no blocking involved globally.
Client Side
Store data in template instance using ReactiveVar
You can store ReactiveVar in the template instance. A ReactiveVar is similar to a Session variable, with a few differences:
ReactiveVars don't have global names, like the "foo" in Session.get("foo"). Instead, they may be created and used locally, for example attached to a template instance, as in:
this.foo.get(). // 'this' is the template instance
ReactiveVars are not automatically migrated across hot code pushes, whereas Session state is.
ReactiveVars can hold any value, while Session variables are limited to JSON or EJSON.
Packages
fs
collection-fs
slingshot: https://atmospherejs.com/edgee/slingshot
go directly to S3
Set ACL to 'private' so only your meteor app can download the file
Use S3 sdk to generate pre-signed url for public download
Upload and download in server https://github.com/VeliovGroup/Meteor-Files/
Upload to any path in server: https://github.com/tomitrescak/meteor-uploads
Last updated