The new Collection API separates query handles from result sets. It
allows template iterators to only redraw changed objects instead of
entire result sets. This implementation also sets the stage for
minimongo indexes and better invalidation performance.
collection.find() now returns a Collection.Query handle. To retrieve
results we provide these methods on Collection.Query:
Iterators (encouraged way to access results):
* query.forEach(function (obj) { ... });
* results = query.map(function (obj) { ... });
Cursor-based retrieval (iterators are built on fetch):
* docs = query.fetch(maxlen); // return next [maxlen] (all) docs.
* doc = query.get(skip); // return next doc, skipping [skip] (0) docs.
Counter:
* length = query.count(); // number of results in query.
Live queries (replaces findLive):
* live_handle = query.observe({added: function (obj, idx) { ... },
removed: function (id, idx) { ... },
changed: function (obj, idx) { ... },
moved: function (obj, old_idx, new_idx) { ... }});
Convenience finders:
* doc = collection.findOne({color: 'red'});
* doc = collection.findOne(id_val);
On the client, calling forEach(), map(), fetch(), get(), or findOne()
inside an invalidation context will register a dependency on the entire
query result. Any change to any objects invalidates the context.
Calling count() inside an invalidation context will register a
dependency that only triggers if objects enter or leave the result set.
Calling observe() does not register a dependency.
Meteor
Meteor is an ultra-simple environment for building modern web applications.
With Meteor you write apps:
- in pure Javascript
- that send data over the wire, rather than HTML
- using your choice of popular open-source libraries
Please, do not share or blog about Meteor yet. It is experimental, pre-release software. We hope it shows the direction of our thinking, and much of it will to change. We'd love to hear your feedback.
Documentation is available at http://preview.meteor.com/
Quick Start
Install Meteor (only OS X, for now):
curl -sL bit.ly/n122Iu | /bin/sh
Create a project:
meteor create try-meteor
Run it:
cd try-meteor
meteor
Deploy it to the world, for free:
meteor deploy try-meteor.meteor.com
Slow Start (for developers)
If you want to run on the bleeding edge, or help develop Meteor, you can run Meteor directly from a git checkout.
git clone git@github.com:meteor/meteor.git
cd meteor
If you're the sort of person who likes to build everything from scratch, you can build all the Meteor dependencies (node.js, npm, mongodb, etc) with the provided script. If you do not run this script, Meteor will automatically download pre-compiled binaries when you first run it.
# OPTIONAL
./admin/generate-dev-bundle.sh
Now you can run meteor directly from the checkout (if you did not build the dependency bundle above, this will take a few moments to download a pre-build version).
./meteor --help
Or install to /usr/local like the normal install process. This
will cause meteor to be in your PATH.
./install.sh
meteor --help
Developer Resources
Get in touch! We'd love to hear what you think. You can get involved in several ways:
- Announcement list: sign up at http://preview.meteor.com/
- Google group for discussion: http://groups.google.com/group/meteor-users
- IRC:
#meteoronirc.freenode.net - Email us:
contact@meteor.com