sql-switch - v1.0.1
    Preparing search index...

    Class WriteOperation<T>

    A pending write that is both awaitable and chainable with .force().

    The write is already scheduled by the time you hold one of these (see KeyProxy.set => eager). Awaiting it waits for the queued write (or the driver write, when the collector is off); calling .force() skips the collector and writes to the driver immediately.

    // queued — the write is buffered the moment set() is called; await just waits for that
    await db.schema('economy').table('balances').key('user_1').set({ coins: 100 });

    // immediate — resolves only once the DB has actually written it
    await db.schema('economy').table('balances').key('user_1').set({ coins: 100 }).force();

    Type Parameters

    • T

      Resolved value type (always void for the current write operations).

    Implements

    • PromiseLike<T>
    Index
    • Type Parameters

      • T

        Resolved value type (always void for the current write operations).

      Parameters

      • queued: () => Promise<T>
      • immediate: () => Promise<T>

      Returns WriteOperation<T>

    • Makes the operation awaitable => waits for the already-scheduled (collector) write.

      Type Parameters

      • R1 = T
      • R2 = never

      Parameters

      • OptionalonFulfilled: ((value: T) => R1 | PromiseLike<R1>) | null
      • OptionalonRejected: ((reason: unknown) => R2 | PromiseLike<R2>) | null

      Returns PromiseLike<R1 | R2>

    • Bypass the write collector & execute against the database right now.

      Returns Promise<T>