From fa94250daaa951bc8811b72dce7ff11f9dd05f57 Mon Sep 17 00:00:00 2001 From: Sebastian Mayr Date: Fri, 29 Mar 2013 18:50:59 +0100 Subject: [PATCH 1/2] Fixes findOne if no data is cached. --- client.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client.js b/client.js index af493b6..e5d98f9 100644 --- a/client.js +++ b/client.js @@ -54,7 +54,7 @@ function($rootScope, MeteorCollections, $meteorObject) { //console.log(document); if (!array) { - value = new $meteorObject(collection, document); + _.extend(value, document); } if (array) { value[atIndex] = new $meteorObject(collection, document); @@ -79,8 +79,9 @@ function($rootScope, MeteorCollections, $meteorObject) { return value; } Collection.findOne = function(selector, options, callback) { - value = this instanceof Collection ? this : {}; - value = new $meteorObject(collection,collection.find(selector,options).fetch()[0]); + var doc = collection.find(selector, options).fetch()[0]; + if (!doc) doc = {}; + value = new $meteorObject(collection, doc); this.observe(collection.find(selector, options), false); return value; } From 3f70f766984360ff725717f8ef4115d2200b072d Mon Sep 17 00:00:00 2001 From: Sebastian Mayr Date: Sat, 30 Mar 2013 00:03:51 +0100 Subject: [PATCH 2/2] Fixes changedAt event on single records. --- client.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client.js b/client.js index e5d98f9..70276d6 100644 --- a/client.js +++ b/client.js @@ -62,8 +62,11 @@ function($rootScope, MeteorCollections, $meteorObject) { $rootScope.apply(); }, "changedAt" : function(newDocument, oldDocument, atIndex) { - - value[atIndex] = new $meteorObject(collection, newDocument); + if (array) { + value[atIndex] = new $meteorObject(collection, newDocument); + } else { + _.extend(value, newDocument); + } $rootScope.apply(); }, "removedAt" : function(oldDocument, atIndex) {