Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiny bugfix in the docs example code #156

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/client/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ <h2 id="meteor_deps"><span>Meteor.deps</span></h2>

// If we're inside a context, and it's not yet listening to
// temperature changes..
if (context && !this.listeners[context.id])
if (context && !this.listeners[context.id]) {
// .. add it to our list of contexts that care about the temperature ..
this.listeners[context.id] = context;

Expand Down
20 changes: 18 additions & 2 deletions packages/minimongo/minimongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,14 @@ LocalCollection.Cursor.prototype._markAsReactive = function (options) {
// this in our handling of null and $exists)
LocalCollection.prototype.insert = function (doc) {
var self = this;
doc = LocalCollection._deepcopy(doc);
doc = LocalCollection._deepcopy(doc, self["default"]);

// XXX deal with mongo's binary id type?
if (!('_id' in doc))
doc._id = LocalCollection.uuid();
// XXX check to see that there is no object with this _id yet?

console.log(doc)
self.docs[doc._id] = doc;

// trigger live queries that match
Expand Down Expand Up @@ -367,7 +370,7 @@ LocalCollection.prototype._modifyAndNotify = function (doc, mod) {

// XXX findandmodify

LocalCollection._deepcopy = function (v) {
LocalCollection._deepcopy = function (v, inherit) {
if (typeof v !== "object")
return v;
if (v === null)
Expand All @@ -379,11 +382,24 @@ LocalCollection._deepcopy = function (v) {
return ret;
}
var ret = {};
if (inherit) {
ret = LocalCollection._createObject(inherit);
}

for (var key in v)
ret[key] = LocalCollection._deepcopy(v[key]);
return ret;
};

// Creates a new Object inherited from the object that is passed.

LocalCollection._createObject = Object.create || function(o) {
var Func;
Func = function() {};
Func.prototype = o;
return new Func();
};

// XXX the sorted-query logic below is laughably inefficient. we'll
// need to come up with a better datastructure for this.

Expand Down