Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit dfab25b

Browse files
committed
Add a set method and change update to perform non-destrutive updates. Fixes #4
1 parent b029f53 commit dfab25b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

angularFire.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,22 @@ angular.module("firebase").factory("angularFireCollection", ["$timeout",
371371
}
372372
};
373373

374-
// Update an object in the remote collection.
374+
// Incrementally update an object in the remote collection.
375375
collection.update = function(itemOrId, cb) {
376376
var item = angular.isString(itemOrId) ?
377377
collection[indexes[itemOrId]] : itemOrId;
378-
// Update all properties, unless they're ones created by Angular.
378+
var copy = angular.fromJson(angular.toJson(item));
379+
if (!cb) {
380+
item.$ref.update(copy);
381+
} else {
382+
item.$ref.update(copy, cb);
383+
}
384+
};
385+
386+
// Update an object in its entirety in the remote collection.
387+
collection.set = function(itemOrId, cb) {
388+
var item = angular.isString(itemOrId) ?
389+
collection[indexes[itemOrId]] : itemOrId;
379390
var copy = angular.fromJson(angular.toJson(item));
380391
if (!cb) {
381392
item.$ref.set(copy);

angularfire.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)