Docs : SDK : openDatabase
openDatabase lets you retrieve your user's data. You also need to have a database open before storing or modifying user data. This API will return a promise that gets resolved once the database becomes available for use.
userbase.openDatabase({
databaseName: 'example-database-name',
changeHandler: function (items) {
// update your application state with the database items
}
}).then(() => {
// the database can now be used
}).catch((e) => console.error(e))
Parameters
-
databaseName [string | Len: 1-50] - The database name to use.
-
changeHandler [function] - A callback that gets invoked when the database gets modified.
-
items [Array] - The full collection of items in the database, in insertion order.
- itemId [string] - The item's unique identifier.
- item [object] - The stored item.
Errors
- ParamsMustBeObject
- DatabaseAlreadyOpening
- DatabaseNameMissing
- DatabaseNameMustBeString
- DatabaseNameCannotBeBlank
- DatabaseNameTooLong
- ChangeHandlerMissing
- ChangeHandlerMustBeFunction
- UserNotSignedIn
- UserNotFound
- TooManyRequests
- ServiceUnavailable