Skip to content

Instantly share code, notes, and snippets.

@benstr
benstr / user-schema.js
Created June 17, 2015 14:55
user schema
UserProfileSchema = new SimpleSchema({
orgId : {
type: String,
regEx: /^[a-z0-9A-z .]{3,30}$/,
optional: true
},
staffId : {
type: String,
regEx: /^[a-z0-9A-z .]{3,30}$/,
optional: true

TL;DR

A query defines a set of conditions on a collection of documents. Most of the time, only the documents that meet these conditions need to be published to the client. In many cases the query's conditions are subject to the state of the application (for instance the selected sorting field). This pattern describes how to update your query's result set reactively with meteor without losing the cursor's state. This way, results are preserved over different adjustements of a query if they meet both set of conditions.

an example case

To illustrate this pattern best, we'll be using the following example case throughout.

Let's say you have a collection of Players and a collection of Games. We track each score in a Scores collection. Some example data:

Players:

@benstr
benstr / meteor-full-stack-learn.md
Last active October 1, 2021 11:52
Meteor Full Stack How To Learn

#How do I become a web app developer - Meteor style

What does an aspiring web developer need to know to develop a Meteor app? Below is a list of languages, frameworks, libraries, packages & more ;) .

The lists that follow are purposely ordered, unless noted. This article does not explain why you need to learn each item (that is up to you to figure out). Instead this article's purpose is to provide a quick roadmap or "thousand mile" view of the technologies a Meteor Dev works with daily.

When you are in the weeds of learning new things it feels good knowing you have a map to reference and measure your progress against.

nemo's escape

@benstr
benstr / changes_keys_example.js
Created December 8, 2014 13:10
Iterate over data and change keys
Template.usersIndex.helpers({
items: function() {
var users = Meteor.users.find({}).fetch();
_(users).forEach().forEach(function(num) { console.log(num); }).join(',');
var items = users.filter(function(user) {
return user;
}).map(function(user){
return {
name: user.profile.name,
description: user.emails[0].address,

App Dev Process

Premise: Many small wins, short sprints, frequent collaboration, k.i.s.s. every step.

Stage 1 Discovery

  1. Understand that YOU do not understand.
  2. Gain understanding by interviewing end-users & mapping current process.
  3. Iteration #001: Deduce current process to the most basic needs.
  4. Iteration #001: Plan a data model for just the basic needs.
  5. Iteration #001: Design a user interface for just the basic needs.
@benstr
benstr / router.js
Created November 11, 2014 14:25
Snippet that requires most Meteor views to render a login form if !currentUser.
Router.configure({
layoutTemplate: "layout",
notFoundTemplate: "notFound",
loadingTemplate: "loading"
});
if(Meteor.isClient) {
var publicRoutes = ["userRequest", "userPassForgot", "userPassReset"];
}
@benstr
benstr / Meteor_uihooks.md
Last active January 25, 2022 09:02
_uihooks Examples

Add preliminary API for registering hooks to run when Blaze intends to insert, move, or remove DOM elements. For example, you can use these hooks to animate nodes as they are inserted, moved, or removed. To use them, you can set the _uihooks property on a container DOM element. _uihooks is an object that can have any subset of the following three properties:

  • insertElement: function (node, next): called when Blaze intends to insert the DOM element node before the element next
  • moveElement: function (node, next): called when Blaze intends to move the DOM element node before the element next
  • removeElement: function (node): called when Blaze intends to remove the DOM element node

Note that when you set one of these functions on a container element, Blaze will not do the actual operation; it's your responsibility to actually insert, move, or remove the node (by calling $(node).remove(), for example).

https://github.com/meteor/meteor/blob/30fb11f1fa0227f1c0ec3eb30b7864ea3b2d210e/History.md

@benstr
benstr / mergeJSON.js
Created November 4, 2014 06:54
Node script to deep merge JSON files
var merge = require('deepmerge');
var fs = require('fs');
var a = require('./json/a-start.json');
var b = require('./json/collections.json');
var c = require('./json/z-sample-fields.json');
var merge1 = merge(a, b);
var merge2 = merge(merge1, c);
@benstr
benstr / package-symlink-instructions.md
Created November 3, 2014 22:09
How to modify an Atmosphere package with forking and symlink