Userbase

SDK : Transaction

Transaction lets you submit multiple database operations as a single atomic batch. Either all operations succeed, or the entire batch fails. You will never see partial updates. This API will return a promise that gets resolved once the transaction has been fully applied and durably persisted in the database.

    
    const operations = [
      { command: 'Update', item: { todo: 'Item A' }, id: '0001' },
      { command: 'Insert', item: { todo: 'Item B' }, id: '0002' },
      { command: 'Delete', item: { todo: 'Item C' }, id: '0003' }
    ]

    userbase.transaction(databaseName, operations)
      .then(() => {
        // transaction applied
      })
    .catch((e) => console.error(e))
    
  

Parameters

Errors