Commit Graph

107 Commits

Author SHA1 Message Date
Naomi Seyfer
24c4b0615d Mostly switching over to using EJSON.equals 2013-01-17 15:56:12 -05:00
Naomi Seyfer
be8c94c899 Switch from LocalCollection._deepcopy to EJSON.clone 2013-01-17 15:55:41 -05:00
David Glasser
7a75b8418a ObjectID detection: Use existence of Meteor.Collection, not isClient. 2013-01-17 15:51:57 -05:00
Naomi Seyfer
c99c816331 Fixing up docs, making ObjectID consistent with Node api 2013-01-17 15:51:56 -05:00
Naomi Seyfer
5b4910c965 First draft of docs for types. 2013-01-17 15:49:52 -05:00
Naomi Seyfer
3331e1f7d3 Glasser's comments on my diff
* Lots of small things like whitespace fixes
* change the way adding a custom type works
2013-01-17 15:49:48 -05:00
Naomi Seyfer
2b7751fa5c Export idParse and idStringify in Meteor 2013-01-17 15:47:25 -05:00
Naomi Seyfer
e831608f86 Moving code around; renamed idToDDP etc to idStringify etc 2013-01-17 15:46:41 -05:00
Naomi Seyfer
3068fd1a36 ObjectID collections now an option not the default 2013-01-17 15:42:34 -05:00
Naomi Seyfer
701d76fe61 Now switching actual collections over to using ObjectID
Previously, had only switched over the default for minimongo --
so there's lots of stuff that actually didn't work.

With this change, two tests are still failing; I will fix them and
then do some more cleanup tomorrow.
2013-01-17 15:42:33 -05:00
Naomi Seyfer
9e130bb398 Self-reviewing my code makes me want to fix problems 2013-01-17 15:42:05 -05:00
Naomi Seyfer
5d93d60aa6 All tests now pass after switching the defualt Collection to ObjectID
**Caveats:**
 - I have not written any more tests; I perhaps should
 - I have not yet written any code to keep current Collections from mixing
   strings and ObjectIDs
 - I don't actually know if the default should be ObjectID.  I should discuss
    with people about this.
2013-01-17 15:41:18 -05:00
Naomi Seyfer
f8fefe7aae Force all keys inside minimongo to be strings
... but preserve other types on the outside of minimongo.
So far passing all current regression tests, but moment of truth
when we switch over to ObjectID yet to come.
2013-01-17 15:39:57 -05:00
Naomi Seyfer
432e8ccd98 ObjectID as a value in DDP 2013-01-17 15:30:25 -05:00
Naomi Seyfer
33e0a52c5c ObjectId conversion to/from DDP ids 2013-01-17 15:30:24 -05:00
Naomi Seyfer
1de0a87b84 Client-side ObjectId object 2013-01-17 15:29:51 -05:00
Naomi Seyfer
48203263e3 In the client, now all internal "abstract ddp" uses fieldName: undefined
Instead of a cleared list.  The wire format still has a cleared list.
2013-01-17 15:29:05 -05:00
Dana Woodman
d17fb77189 Fix spelling error
Missing 'n'.
2013-01-08 20:35:11 -08:00
David Glasser
8a2328b27f Fix lookup by fields beginning with numbers (broken by 2d2aaa808). 2012-12-27 16:32:55 -08:00
David Glasser
8ad174eead Feedback from review of skip/limit fix:
- Keep upsert as an error.
- Keep if (before||after) check.
- Add some comments.
2012-12-18 10:19:53 -08:00
David Glasser
e9913d2055 Fix to skip/limit observe: update would never produce 'changed' calls.
Also remove dead upsert code.
2012-12-17 23:39:13 -08:00
David Glasser
2d2aaa8082 minimongo: Implement ordinal indexing: {'foo.1.bar': 42} 2012-12-17 21:35:12 -08:00
Nick Martin
48423c21d0 Feedback from review. 2012-12-17 14:53:40 -08:00
Nick Martin
4c78d3dc51 Make sub-key sort check for undefined before dereferencing.
This way it doesn't throw when given an object that doesn't contain all the keys being searched on.
2012-12-17 14:53:40 -08:00
Nick Martin
7b8682b3fb Test for sub-key sort. Doesn't pass yet. 2012-12-17 14:53:40 -08:00
lvbreda
bd94569d86 Added sorting functionality for 'a.b' 2012-12-17 14:53:40 -08:00
David Glasser
e32502c20c Add a fast path to limited unsorted unskipped queries. 2012-12-17 14:44:02 -08:00
David Glasser
ac81438f74 Refinements to limit/skip observe support:
- Decide that queries need to be recomputed in _modifyAndNotify directly
   instead of in _removeFromResults and friends; this is because the choice of
   which _fooFromResults function to invoke might not actually be correct in the
   presence of skip and limit. (The previous code still worked because all three
   of those functions had the same code for the skip/limit case.)

 - If update or remove affects more than one doc for a query, only recompute it
   once at the end instead of once per doc.
2012-12-17 14:44:02 -08:00
Nick Martin
33fa24e912 Make find(1) and find({_id: 1}) return the same thing. 2012-12-17 14:44:02 -08:00
Nick Martin
2d9e8a8fd6 Move some tests around. No functional changes. 2012-12-17 14:44:02 -08:00
Nick Martin
0faaa07c77 Feedback from review. 2012-12-17 14:44:02 -08:00
Nick Martin
aee54f3ac0 Add skip and limit support to observe. 2012-12-17 14:44:02 -08:00
David Glasser
c941363d64 Make minimongo test parse on IE7 unminified. 2012-12-04 14:47:40 -08:00
David Glasser
77f926639b Make minimongo tests pass in old browsers (FF3.6, IE8).
(Broken test added in 129154695455282a.)
2012-12-04 14:47:40 -08:00
meawoppl@gmail.com
3f0a5a3489 Fixed flaw in uuid generation where dynamic casting from hex string to integer
give the improper result for characters a-f.

See below for related snippet, spaced to make reading easy
X marks the spot!:
>  s
["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]

>  _.map(s, function(input) { return ((input & 0x3)| 0x8)})
[ 8,   9,   10,  11,  8,   9,   10,  11,  8,   9,   8,   8,   8,   8,   8,   8]
                                                    X,   X,        X,   X,   X
_.map(s, function(input) { return ((parseInt(input,16) & 0x3)| 0x8)})
> [8,  9,   10,  11,  8,   9,   10,  11,  8,   9,   10,  11,  8,   9,   10, 11]
2012-12-02 12:43:50 -08:00
David Glasser
add592a32e minimongo: Test observing a query-by-ID.
Demonstrates that the optimization in PR #504 is not safe.
2012-11-28 11:01:30 -08:00
David Glasser
4acd2551e4 Refactor $and/$or/$nor compilation. 2012-11-28 10:53:32 -08:00
Christian Schramm
eca9d705ae Fixed bug where $and/$or/$nor accepted empty arrays
mongodb doesn't accept it, so we follow its example. Also fixed test
for that.
2012-11-28 10:48:17 -08:00
Christian Schramm
1291546954 Added $where tests 2012-11-28 10:48:17 -08:00
Christian Schramm
f080fb20e4 Added $and tests 2012-11-28 10:48:16 -08:00
Christian Schramm
7f89f059e5 Added test for $or and $nor 2012-11-28 10:48:16 -08:00
David Glasser
f8c54c4046 Overhaul quiescence, method callback timing, and login methods on the client.
- Data streamed from the server is quiesced on a per-object basis, not a global
  basis. We track which documents a method stubs modifies, and create individual
  snapshots ("server documents") of those documents rather than whole-Collection
  snapshots. Data writes from the server to documents not modified by stubs are
  applied immediately to the local cache; other writes are applied to the
  "server document" snapshots. Server documents are flushed to the local cache
  when all method stubs that wrote to the document have sent their "data write"
  message.  (We still do "full database" quiescence after a reconnect.)

- Instead of calling method callbacks as soon as the result is received, we wait
  until all data that precedes their "data done" message is flushed to the local
  cache. This way, method callbacks can see all of their results locally. (This
  applies to Collection mutator callbacks as well.) If this delay is
  unacceptable, you can also specify the onResultReceived option to
  Meteor.apply; this callback is given the method result as soon as it comes in,
  and there's no guarantee that the local cache is up to date.
  (This is a client-only change: server-side callbacks do not block on the
  write fence.)

- Methods invoked with the "wait" option to Meteor.apply now wait until all
  preceding methods are fully finished to be *sent*, not just to call their
  callbacks. ie, previous calls block the "wait" method in the same way that
  "wait" methods block subsequent calls.

- Remove Meteor.userLoaded and {{currentUserLoaded}}.
  Meteor.userId() is now set only at the point where Meteor.user() is fully
      loaded.
  Current user data is published via an unnamed subscription, not via
      "meteor.currentUser".
  Replace them with Meteor.loggingIn() and {{loggingIn}}, which become true
      as soon as the login method is sent (instead of only once it succeeds).
  In accounts-ui, move the spinny into the dropdown, because it now shows up
      before error messages would.

- Previously, if we received the "result" message from a method but no "data"
  message, and then disconnected and reconnected, quiescence would be
  permanently blocked. Now, not only do we allow the app to continue working,
  but we even guarantee that the method's callback will be called at the
  "reconnect quiescence" point.

- Remove reset function from the Store API (the interface between
      _LivedataConnection and Collection), and add a boolean "reset" argument to
      beginUpdate instead.
  Add saveOriginals/retrieveOriginals functions to the Store API (pass-through
      to minimongo implementation).
  Allow "replace" messages to be passed to the Store API's update function
      (in addition to set/unset).
  Allow Store API implementations (eg tinytest_client) to not specify all
      functions.

- Server-side tinytest results now stream into the result page instead of
  appearing all at once at the end.

- Rename fields and methods of Meteor._LivedataConnection as camelCase, and
  prepend all internal fields with _.

- Different Meteor._LivedataConnection objects now have separate
  _userIdListeners _ContextSets.

- Remove snapshot/restore functionality from Minimongo collections. (Individual
  queries still have result snapshots.) The "server documents" in
  Meteor._LivedataConnection serve the equivalent purpose.

- Meteor.loginWithToken's callback is now a "call with error on error, call
  with no args on success" callback like the other login callbacks.

- The test-only Meteor._LivedataConnection.onQuiesce function is removed.
  Every single use of it is now supported by normal method callbacks.
2012-11-14 18:10:08 -08:00
David Glasser
ac4b0d687b Add saveOriginal/retrieveOriginal methods to LocalCollection.
This will eventually be used to replace snapshot/restore. snapshot/restore are
used to implement full-database quiescence; saveOriginal/retrieveOriginal will
be used to implement per-object quiescence.

Also, throw on duplicate-ID insert.
2012-11-14 18:10:08 -08:00
Tom Coleman
c27941589c Fixed a problem with deep object selectors with differing keys in minimongo.
Select from minimongo would match objects who different in deep keys (not
values). It seems like the object matching of selector.js was intended to work
this way (the name `b_keys` implies that it should be the keys of `b` after
all), but was mis-implemented.

Fixes #455 - a subtle bug with almost-overlapping subscriptions

(glasser added another test case and cleaned up test whitespace.)
2012-11-05 10:09:17 -08:00
David Glasser
ab8c03e6f7 Add an internal-only (for now) Cursor._observeUnordered API.
Unordered observations have no moved callback and don't pass indices to the
other callbacks. This is used for the automatic cursor publication (because DDP
collections are not ordered) and for Cursor.count(). Internally, the results of
unordered observations are stored as objects instead of an array. This change
has no publicly observable changes, but should increase performance, especially
server-side (since the _diffQuery that drives DDP subscription updates no longer
needs the full complexity of the ordered move detector).

Also, minor optimization to LocalCollection.Cursor._getRawObjects where the
selector is a single ID that is not in the collection (now O(1) instead of
O(n)).
2012-11-02 12:10:47 -07:00
Avital Oliver
2033728f29 Some debugging improvements 2012-10-12 22:42:54 -07:00
David Glasser
7a25d86dc0 Update the docs for the removed callback to Cursor.observe. 2012-10-04 18:28:12 -07:00
David Glasser
57c3c2a50d _diffQuery: don't compare docs if there's no changed observer. 2012-10-04 14:05:06 -07:00
David Glasser
2768abd5c3 Fix IE7 minimongo test failure: don't use LocalCollection._f._equal on Dates.
(We should eventually make all the selector code support Dates, but until then,
don't use it.)
2012-09-20 17:04:50 -07:00
David Glasser
5e622215ba Change all publicly documented APIs to use camelCase.
For now, the old names still work as well.

This includes:
  - Meteor.isServer/isClient
  - this.isSimulation in methods
  - Context.onInvalidate
  - Meteor.status().retryCount/retryTime

Remove old backwards-compatibility "Sky" alias for "Meteor".

Update all examples in the docs to use camelCase.

Delete unused docs/client/projects.html file.
2012-09-17 14:26:45 -07:00