Commit Graph

50 Commits

Author SHA1 Message Date
David Greenspan
df8567dba3 dedup Mongo cursors 2012-04-03 22:40:36 -07:00
David Greenspan
dc2902dde0 snapshots changes with Geoff (comments) 2012-04-03 22:37:12 -07:00
Nick Martin
4f89af1aaa Test snapshot/restore and pause/resume. 2012-04-03 22:37:12 -07:00
Nick Martin
39256dc52f Also diff on snapshot/restore. Makes no difference in practice as we are always paused when we call restore. 2012-04-03 22:37:12 -07:00
David Greenspan
4dc8944fb4 deepcopy observer callback arguments, only on client 2012-04-03 22:37:11 -07:00
David Greenspan
bf04fccb72 new query diffing algorithm with fuzz tests 2012-04-03 22:37:11 -07:00
Nick Martin
ee1d25f499 Implement pause/resume in Minimongo. Uses a pessimal diff algorithm. 2012-04-03 22:37:11 -07:00
Nick Martin
5a1ecf6d16 Events test helper, plus misc test fixups. 2012-03-28 18:26:15 -07:00
matt debergalis
7377ce2041 Major formatting and content update to docs. 2012-03-20 16:55:30 -07:00
Geoff Schmidt
b3fc3150d4 simplify signature of observe()'s remove callback 2012-03-16 18:26:19 -07:00
Geoff Schmidt
76c57526f7 rework public API for defining tests 2012-03-02 05:22:40 -08:00
Geoff Schmidt
cab5afbb91 move test reporting functions out of globals 2012-03-02 03:57:30 -08:00
matt debergalis
c0b3df5a91 Sync Minimongo observe API to server.
Return old document in callbacks.  Add LiveResultsSet.collection to
match server.

Add observe() unit test suite.
2012-02-29 16:08:58 -08:00
matt debergalis
cb887f5a9b Rework livedata (DDP) subscriptions.
Publish now comes in three flavors:

* Bare metal API: Meteor.publish(name, func).

  Server will call func(sub, params) each time a client subscribes to
  "name" (with supplied "params"), or if "name" is null, each time a new
  client connects (autopublish).  "sub" is a Subscription object, which
  supplies sub.set(), sub.unset(), sub.satisfies(), and sub.flush()
  methods to emit DDP data messages.  func() should register a cleanup
  function with sub.onStop(), which will be called when client unsubs.

  To react to database changes, use Collection.observe().  Publish
  functions that are not database backed may use some other mechanism
  (setInterval?) to schedule calls to sub.set().

* publishCursor API:

  If func() *returns* a Cursor, server will automatically publish all
  results from that cursor as the collection with the same name as the
  cursor's underlying Mongo collection.  For example:

  Meteor.publish('top10', function (sub, params) {
    return Players.find({}, {sort: {score: -1}, limit: 10});
  });

  will define a 'top10' publish that is always the top 10 scoring
  players, published to the 'players' collection on each subscribing
  client.

* autopublish

  When the autopublish package is loaded, all Collections defined on the
  server will automatically be published, in their entirety, to each
  connected client.  Clients need not call Meteor.subscribe().  Calls to
  publish() will emit a warning message, since they are superflous.  To
  disable autopublish, run "meteor remove autopublish".
2012-02-29 16:08:58 -08:00
David Greenspan
5aeff801c3 deepcopy consistently in minimongo callbacks (to not mask bugs) 2012-02-29 13:16:16 -08:00
Geoff Schmidt
5cf9351ecd Test compound methods, including clients cheating 2012-02-29 04:36:51 -08:00
Geoff Schmidt
7a8e7f5ea3 data refactoring cleanups in some tests 2012-02-17 01:33:18 -08:00
Geoff Schmidt
f31226e388 rename minimongo Collection => LocalCollection 2012-02-16 22:41:16 -08:00
matt debergalis
b84f048c75 harmonize style: no parens after typeof 2012-02-10 15:43:12 -08:00
Geoff Schmidt
6118837311 Solve the "time travel" problem using database snapshots. 2012-02-09 22:27:48 -08:00
Nick Martin
bd02b31a55 move uuid to it's own package, so stream can depend on it. 2012-02-06 23:15:31 -08:00
matt debergalis
6a0831d9b0 Align Minimongo and MongoDB semantics.
* remove() removes all documents in collection (previously, had to
  explicitly pass {} selector to MM).

* update() requires {multi: true} to update multiple documents.
  Previously we defaulted to true, now multi defaults to false.
2012-02-06 18:17:53 -08:00
matt debergalis
42f82d9f63 don't use options.limit in findOne() 2012-02-02 18:12:20 -08:00
matt debergalis
6851bf66ae Make falsey and {_id: <falsey>} selectors match nothing.
In Livedata and Minimongo, make falsey selectors match no documents,
instead of all documents.  Same for {_id: undefined}.  This is a
departure from most MongoDB drivers, but offers a safety belt around
selectors that are rarely useful and easy to accidentally create
programmatically.

For remove(), also protect against accidentally destroying an entire
collection when passing no args.  To empty a collection, pass the
wildcard selector explicitly: foo.remove({});

For find(), keep the standard mongo behavior of returning all documents
when no selector is passed in by explicitly checking arguments.length.

This change also makes typical read cases cleaner, allowing:

 x = foo.findOne(Session.get('foo_id'));

instead of

 x = Session.get('foo_id') && foo.findOne(Session.get('foo_id'));
2012-02-02 16:46:43 -08:00
Nick Martin
93ff43bb78 Remove stray console.log. 2012-01-30 12:42:23 -08:00
matt debergalis
0fa1d39cf7 simplify Collection API.
drops get(), fetch(n), and Collection.STOP
2012-01-30 12:03:06 -08:00
matt debergalis
fbf143a7e6 drop LiveResultsSet#indexOf 2012-01-28 18:38:44 -08:00
David Greenspan
f2e6838691 fixes to minimongo, test driver, and tests 2012-01-28 00:10:35 -08:00
matt debergalis
5e7daaaff3 New Collection API
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.
2012-01-27 20:59:08 -08:00
Geoff Schmidt
d1d5604976 Refactor bundler; new package API 2012-01-27 20:02:26 -08:00
David Greenspan
6108c56dfd fix test CSS 2012-01-27 20:02:25 -08:00
Geoff Schmidt
e5eb42e55c Refactor package API/bundler 2012-01-27 20:02:24 -08:00
Nick Martin
459dac9cac Merge branch 'master' into meteor
conflicts hand resolved. deftemplate and liveui reverted to master, will re-do later.

Conflicts:
	admin/generate-dev-bundle.sh
	admin/install-s3.sh
	admin/manifest.json
	app/meteor/deploy.js
	app/meteor/meteor.js
	examples/leaderboard/leaderboard.js
	examples/unfinished/azrael/client/azrael.js
	examples/unfinished/azrael/model.js
	packages/liveui/liveui.js
	packages/templating/deftemplate.js
	packages/templating/html_scanner.js
	tests/minimongo/test.html
2012-01-18 16:14:54 -08:00
Geoff Schmidt
8cc4bc3aeb Package JSON cleanly. minimongo test passes on IE7 2012-01-16 23:03:07 -08:00
Geoff Schmidt
f0ff237168 LiveRange tests pass on IE7!
When your app ships your own JSON.stringify, anyway.
2012-01-16 22:50:27 -08:00
Geoff Schmidt
8653639a2d fix some IE7 issues 2012-01-16 22:12:49 -08:00
Nick Martin
3faff2de78 perl -pi -e 's/Sky/Meteor/g' **/* 2012-01-04 20:52:46 -08:00
Nick Martin
23cd5b6912 perl -pi -e 's/Skybreak/Meteor/g' **/* 2012-01-04 18:30:25 -08:00
Geoff Schmidt
eb146494f7 comment 2011-12-19 17:03:26 -08:00
Geoff Schmidt
f0df8212ee reimplement #each in terms of renderList
not tested yet
2011-12-19 17:03:26 -08:00
Geoff Schmidt
fabfa902bf renderList reimplemented for documentfragments.
there may be bugs. leaderboard works though
2011-12-19 17:03:26 -08:00
Geoff Schmidt
3666cff408 redo Sky.deps api for clarity and flexibility
especially the ability for the caller of monitor to grab the invalidation function
2011-12-19 16:39:28 -08:00
Nick Martin
56b9273680 IE8 fix. eval doesn't actually return a value. 2011-12-09 13:42:58 -08:00
Geoff Schmidt
24692a60f5 rationalize underscore usage slightly 2011-12-08 16:28:47 -08:00
Geoff Schmidt
ce565dcaea kill basics package 2011-12-07 22:28:43 -08:00
matt debergalis
08ec11e2e7 good replacement for Math.random() and provide a UUID generator.
on the client, minimongo defines (and relies on) Collection.random()
and Collection.uuid() to generate _id values.

on the server, livedata defines (and relies on) Sky.random()
and Sky.uuid() for the same.

random/uuid code is duplicated, as it was before.
2011-12-07 13:03:11 -08:00
Nick Martin
1d4f97de34 Work around issue in IE8. 2011-12-01 21:29:33 -08:00
Geoff Schmidt
948388a430 comment 2011-11-29 00:21:28 -08:00
Geoff Schmidt
89b4263ec1 refactor Sky.deps for clarity 2011-11-26 22:49:42 -08:00
Nick Martin
d69c2d1f19 Initial import from old busted repo. 2011-11-17 18:35:20 -08:00