UNPKG

@tragedy-labs/sprite

Version:

A TypeScript driver for ArcadeDB

41 lines (40 loc) 1.54 kB
import { DatabaseSession } from '../session/DatabaseSession.js'; import { ArcadeSupportedQueryLanguages } from '../database/Database.js'; /** * A transaction in Sprite, contains the transaction id, and methods to * commit or rollback the transaction. * @param session the `DatabaseSession` the transaction is taking place of * @param transactionId the id of the transaction */ export declare class SpriteTransaction { private _session; private _id; /** State */ private _rolledBack; private _committed; constructor(session: DatabaseSession, transactionId: string); /** The trasaction ID */ get id(): string; /** Whether or not the transaction has been rolledback */ get rolledBack(): boolean; /** Whether or not the transaction has been committed */ get committed(): boolean; /** * Commit the transaction. * @returns `true` if the transaction was commited. */ commit: () => Promise<boolean>; /** * Rollback the transaction. * @returns `true` if the transaction was commited. */ rollback: () => Promise<boolean>; /** * Perform a CRUD operation in the transaction. * @param language the query language to use * @param command the command to execute * @param params the (optional) parameters to pass to the command * @returns the result of the CRUD operation */ crud: <T>(language: ArcadeSupportedQueryLanguages, command: string, parameters?: Record<string, boolean | string | number>) => Promise<T>; }