Skip to content

Commit 528ae3b

Browse files
committed
Handle addition and deletion of documents from the command line, closes #73
1 parent 134dbac commit 528ae3b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

modules/angular-meteor-collections.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,21 @@ angularMeteorCollections.factory('$collection', ['$q', 'HashKeyCopier', '$subscr
8686
return item._id;
8787
}).indexOf(oldItem._id);
8888
if (index == -1) { // To here get all objects that pushed or spliced
89-
if (oldItem._id) { // This is a check to get only the spliced objects
90-
newItems.remove(oldItem._id);
89+
var localIndex;
90+
if (!oldItem._id)
91+
localIndex = -1;
92+
else if (oldItem._id && !oldItem._id._str)
93+
localIndex = -1;
94+
else {
95+
localIndex = newItems.map(function (item) {
96+
if (item._id)
97+
return item._id._str;
98+
}).indexOf(oldItem._id._str);
99+
}
100+
if (localIndex == -1){
101+
if (oldItem._id) { // This is a check to get only the spliced objects
102+
newItems.remove(oldItem._id);
103+
}
91104
}
92105
}
93106
});

0 commit comments

Comments
 (0)