@textile/hub > WriteTransaction > discard
WriteTransaction.discard() method
Discard drops all active transaction changes. It also invalidates the transaction, so it will fail upon calling end.
Signature:
discard(): Promise<void>;
Returns:
Promise<void>
Example
Abort an in-flight transaction
import {Client, ThreadID} from '@textile/hub'
interface Astronaut {
name: string
missions: number
_id: string
}
async function example (client: Client, threadID: ThreadID) {
const buzz: Astronaut = {
name: 'Buzz',
missions: 2,
_id: '',
}
const t = client.writeTransaction(threadID, 'astronauts')
await t.start()
await t.create([buzz])
await t.discard() // Abort
await t.end()
}