Docs : SDK : insertItem
insertItem lets you add items to a user's database. This API will return a promise that gets resolved once the item has been durably inserted into the database.
userbase.insertItem({
databaseName: 'example-database-name',
item: { example: 'Sample Item A' }
}).then(() => {
// item inserted
}).catch((e) => console.error(e))
Parameters
-
databaseName [string | Len: 1-100] - The database name to use.
-
item [object | string | number | boolean | null | Max size: 10 KB] - The item to insert.
-
itemId [string | Len: 1-100 | optional] - The item's unique identifier.
Advanced Parameters
-
shareToken [string | optional] - The token used to access a shared database.
-
databaseId [string | optional] - The database's unique identifier.
-
writeAccess [object | optional] - Access controls for the item.
- onlyCreator [boolean | optional] - If true, only the item creator or database owner can modify the item.
- users [Array | Max: 10 | optional] - The users allowed to modify the item.
Notes
-
All inputs are end-to-end encrypted except for the writeAccess object. The server can see this value so that Userbase can enforce access controls efficiently and reliably, and because keeping it end-to-end encrypted could actually be detrimental to privacy and security.
Errors
- ParamsMustBeObject
- DatabaseNotOpen
- DatabaseNameMissing
- DatabaseNameMustBeString
- DatabaseNameCannotBeBlank
- DatabaseNameTooLong
- DatabaseNameRestricted
- DatabaseIdMustBeString
- DatabaseIdCannotBeBlank
- DatabaseIdInvalidLength
- DatabaseIdNotAllowed
- DatabaseIsReadOnly
- ItemIdMustBeString
- ItemIdCannotBeBlank
- ItemIdTooLong
- ItemMissing
- ItemInvalid
- ItemTooLarge
- ItemAlreadyExists
- TransactionUnauthorized
- UserNotSignedIn
- UserNotFound
- TooManyRequests
- ServiceUnavailable