FirebaseDatabase Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
Classes
The following classes are available globally.
-
A DataSnapshot contains data from a Firebase Database location. Any time
you read Firebase data, you receive the data as a DataSnapshot.
DataSnapshots are passed to the blocks you attach with
observe(_:with:)
or observeSingleEvent(of:with:)
. They are
efficiently-generated immutable copies of the data at a Firebase Database
location. They can’t be modified and will never change. To modify data at a
location, use a DatabaseReference (e.g. with setValue(_:)
).
Declaration
Objective-C
@interface FIRDataSnapshot : NSObject
-
The entry point for accessing a Firebase Database. You can get an instance
by calling Database.database()
. To access a location in the database and
read or write data, use FIRDatabase.reference()
.
Declaration
Objective-C
@interface FIRDatabase : NSObject
-
A DatabaseQuery
instance represents a query over the data at a particular
location.
You create one by calling one of the query methods (queryOrdered(byChild:)
,
queryStarting(atValue:)
, etc.) on a DatabaseReference
. The query methods
can be chained to further specify the data you are interested in observing.
Declaration
Objective-C
@interface FIRDatabaseQuery : NSObject
-
A FIRDatabaseReference represents a particular location in your Firebase
Database and can be used for reading or writing data to that Firebase
Database location.
This class is the starting point for all Firebase Database operations. After
you’ve obtained your first FIRDatabaseReference via [FIRDatabase reference],
you can use it to read data (ie. observeEventType:withBlock:), write data
(ie. setValue:), and to create new FIRDatabaseReferences (ie. child:).
-
A MutableData
instance is populated with data from a Firebase Database
location. When you are using runTransactionBlock(_:)
, you will be given an
instance containing the current data at that location. Your block will be
responsible for updating that instance to the data you wish to save at that
location, and then returning using TransactionResult.success(withValue:)
.
To modify the data, set its value property to any of the Objective-C types
supported by Firebase Database, or any equivalent natively bridgeable Swift
type:
NSNumber
(includes booleans)
NSDictionary
NSArray
NSString
nil
/ NSNull
to remove the data
Note that changes made to a child MutableData
instance will be visible to
the parent.
Declaration
Objective-C
@interface FIRMutableData : NSObject
-
Placeholder values you may write into Firebase Database as a value or
priority that will automatically be populated by the Firebase Database
server.
Declaration
Objective-C
@interface FIRServerValue : NSObject
-
Used for runTransactionBlock(_:)
. A TransactionResult
instance is a
container for the results of the transaction.
Declaration
Objective-C
@interface FIRTransactionResult : NSObject
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-11 UTC.
[null,null,["Last updated 2025-03-11 UTC."],[],[],null,["# FirebaseDatabase Framework Reference\n\nClasses\n=======\n\nThe following classes are available globally.\n- `\n ``\n ``\n `\n\n ### [FIRDataSnapshot](/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRDataSnapshot)\n\n `\n ` \n A DataSnapshot contains data from a Firebase Database location. Any time\n you read Firebase data, you receive the data as a DataSnapshot.\n\n DataSnapshots are passed to the blocks you attach with\n `observe(_:with:)` or `observeSingleEvent(of:with:)`. They are\n efficiently-generated immutable copies of the data at a Firebase Database\n location. They can't be modified and will never change. To modify data at a\n location, use a DatabaseReference (e.g. with `setValue(_:)`). \n\n #### Declaration\n\n Objective-C \n\n\n @interface FIRDataSnapshot : NSObject\n\n- `\n ``\n ``\n `\n\n ### [FIRDatabase](/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRDatabase)\n\n `\n ` \n The entry point for accessing a Firebase Database. You can get an instance\n by calling `Database.database()`. To access a location in the database and\n read or write data, use `FIRDatabase.reference()`. \n\n #### Declaration\n\n Objective-C \n\n\n @interface FIRDatabase : NSObject\n\n- `\n ``\n ``\n `\n\n ### [FIRDatabaseQuery](/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRDatabaseQuery)\n\n `\n ` \n A `DatabaseQuery` instance represents a query over the data at a particular\n location.\n\n You create one by calling one of the query methods (`queryOrdered(byChild:)`,\n `queryStarting(atValue:)`, etc.) on a `DatabaseReference`. The query methods\n can be chained to further specify the data you are interested in observing. \n\n #### Declaration\n\n Objective-C \n\n\n @interface FIRDatabaseQuery : NSObject\n\n- `\n ``\n ``\n `\n\n ### [FIRDatabaseReference](/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRDatabaseReference)\n\n `\n ` \n A FIRDatabaseReference represents a particular location in your Firebase\n Database and can be used for reading or writing data to that Firebase\n Database location.\n\n This class is the starting point for all Firebase Database operations. After\n you've obtained your first FIRDatabaseReference via \\[FIRDatabase reference\\],\n you can use it to read data (ie. observeEventType:withBlock:), write data\n (ie. setValue:), and to create new FIRDatabaseReferences (ie. child:). \n\n #### Declaration\n\n Objective-C \n\n\n @interface FIRDatabaseReference : /docs/reference/ios/firebasedatabase/api/reference/Classes/FIRDatabaseQuery\n\n- `\n ``\n ``\n `\n\n ### [FIRMutableData](/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRMutableData)\n\n `\n ` \n A `MutableData` instance is populated with data from a Firebase Database\n location. When you are using `runTransactionBlock(_:)`, you will be given an\n instance containing the current data at that location. Your block will be\n responsible for updating that instance to the data you wish to save at that\n location, and then returning using `TransactionResult.success(withValue:)`.\n\n To modify the data, set its value property to any of the Objective-C types\n supported by Firebase Database, or any equivalent natively bridgeable Swift\n type:\n - `NSNumber` (includes booleans)\n - `NSDictionary`\n - `NSArray`\n - `NSString`\n - `nil` / `NSNull` to remove the data\n\n Note that changes made to a child `MutableData` instance will be visible to\n the parent. \n\n #### Declaration\n\n Objective-C \n\n\n @interface FIRMutableData : NSObject\n\n- `\n ``\n ``\n `\n\n ### [FIRServerValue](/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRServerValue)\n\n `\n ` \n Placeholder values you may write into Firebase Database as a value or\n priority that will automatically be populated by the Firebase Database\n server. \n\n #### Declaration\n\n Objective-C \n\n\n @interface FIRServerValue : NSObject\n\n- `\n ``\n ``\n `\n\n ### [FIRTransactionResult](/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRTransactionResult)\n\n `\n ` \n Used for `runTransactionBlock(_:)`. A `TransactionResult` instance is a\n container for the results of the transaction. \n\n #### Declaration\n\n Objective-C \n\n\n @interface FIRTransactionResult : NSObject"]]