-
Notifications
You must be signed in to change notification settings - Fork 1
Documentation
Firebase Object is a library used to abstract database logic out of your application. This allows you to have models persist without any extra work.
FirebaseObject is a convenience class that inherits all behaviour of Savable Loadable and Deletable
Allows a model to be saved to firebase
data - JSON data that is saved to firebase.
save () - saves the contents of the data property to firebase.
willSave () - Does nothing in the base class, is called prior to saving.
didSave () - Does nothing in the base class, is called after saving.
Allows a model to be deleted from firebase
delete () - Removes the object record from firebase.
willDelete () - Does nothing in the base class, is called prior to deleting.
didDelete () - Does nothing in the base class, is called after deleting.
shouldDelete - Is called to verify the delete should happen. In this base class this always returns true but can override that to perform additional logic.
This class is for loading information from firebase. This includes loading the object itself, its children, or any other associated objects.
childTypes - An array of classes that are children of the current class.
children - JSON indexed by ID of all child objects loaded for the given object.
associatedObjectTypes - An array of classes that are associated with the current class (Have a linked ID).
associatedObjects - JSON indexed by ID of all associated objects loaded for the given object.
loadAllOfType (type, callback) - Static method that loads all of the objects matching the given class (type). The array of these instances are provided as the first parameter of the callback method.
importData (data) - Data to be loaded into the data property of the object.
loadChildren (childType, callback) - Loads the children of the given child type. This uses the table for the child and searches them for references to the current object's ID. E.g. Parent is Account, Child is Friend. All Friend objects that contain a property called AccountId that matches the uid of the account object will be loaded into the objects children property. The callback will be called upon all children have been loaded.
loadAssociatedObjects (callback) - Loads all associated objects. For each object type in the associatedObjectTypes property if there exists an array in the data for ID's for that type, they will be loaded into the associatedObjects property. E.g. to load all Activity objects, there needs to be an array of ActivityIds the data property, and a request will be made to load each of the objects individually. Once all objects are loaded the callback is called.
loadAssociatedObject (type, id, callback) - Loads a single associated object based on the class(type) and the object ID. Once the object is loaded the callback is triggered.
loadAllChildren (callback) - Loads the children of all of given child types. This uses the table for the child and searches them for references to the current object's ID. E.g. Parent is Account, Child is Friend. All Friend objects that contain a property called AccountId that matches the uid of the account object will be loaded into the objects children property. The callback will be called upon all children have been loaded.
loadSelf (callback) - Loads the current object from firebase based on the uid in the objects data property.
Object path allows specific classes or objects to change the path that is used for contacting firebase.
loadSelfPath - path used for loadSelf call, defaults to defaultTablePath.
saveTablePath - path used for determining the table to save a new object in, defaults to defaultTablePath.
saveTableItemPath - path used for saving an existing item, defaults to deleteTableItemPath.
deleteTableItemPath - path used for deleting an item, defaults to deleteTableItemPath.
defaultTablePath - The default path for the objects table, defaults to UserId/TableName
defaultItemPath - The default path for the object, defaults to defaultTablePath/ObjectUID
loadChildrenPath - The path used for loading children, defaults to UserId/ChildTableName
loadAssociatedPath - The path used for loading associated objects, defaults to UserId/AssociatedTableName/UID
loadChildrenConditionParameter - The parameter used for filtering children, defaults to TableName + Id
loadChildrenConditionValue - The value used for filtering children, defaults to the parent UID.
loadAllPath - The path used for loading all of a given type. Defaults to UserId/TableName