diff --git a/firebase-database-behavior.html b/firebase-database-behavior.html index bacdae3..af85e0d 100644 --- a/firebase-database-behavior.html +++ b/firebase-database-behavior.html @@ -51,6 +51,17 @@ '__onlineChanged(online)' ], + /** + * Remove all data at the current query location. + * + * **Note:** This will remove *all* data at the path of this + * query, regardless of whether it is visible given the current + * query parameters. + */ + remove() { + return this.ref.remove(); + }, + _setFirebaseValue: function(path, value) { this._log('Setting Firebase value at', path, 'to', value) var key = value && value.$key; diff --git a/firebase-query.html b/firebase-query.html index 7224a96..0a531e6 100644 --- a/firebase-query.html +++ b/firebase-query.html @@ -154,8 +154,34 @@ this.__queryChanged(null, this.query); }, + /** + * Returns the data of the child with the specified key. + * + * **Note:** Will return `null` for any child that is not + * matched **by the current query parameters**. + */ child: function(key) { - return this.__map[key]; + return this.__map[key] || null; + }, + + /** + * Push a new item onto the path of this query. + * + * **Note:** If the data pushed does not match current query + * parameters, it will not appear in `data`. + */ + push(data) { + return this.ref.push(data); + }, + + /** + * Remove a child by its specified key. + * + * **Note:** The child matching the specified key will be + * removed whether or not it is visible in the current query. + */ + removeChild(key) { + return this.ref.child(key).remove(); }, get isNew() {