UNPKG

tedious

Version:

A TDS driver, for connecting to MS SQLServer databases.

41 lines (40 loc) • 1.87 kB
import BulkLoad from './bulk-load'; export type Row = unknown[] | { [colName: string]: unknown; }; /** * The TDS byte stream of a bulk load: COLMETADATA, a ROW token per row, * and a DONE token at the end, serialized from the bulk load's row source. * * The payload owns the row source's iterator the way a `for await` loop * would: it requests the first row as soon as it is created, so that a * stream source is observed from the moment it is handed over, and it * closes the source through the iterator's `return()` whenever the bulk * load does not run to completion, whether the rows were being read * ([[Symbol.asyncIterator]]) or never got to be ([[close]]). * * Rows are written into one buffer that lives for the whole bulk load. * Its contents are yielded once it holds a chunk's worth * (`WritableTrackingBuffer.CHUNK_SIZE`), checked after every cell, and at * the end. Rows from a synchronous source are serialized without an * event-loop turn in between; rows from an asynchronous source are awaited * one at a time. * * @private */ export declare class BulkLoadPayload implements AsyncIterable<Buffer> { bulkLoad: BulkLoad; iterator: Iterator<Row> | AsyncIterator<Row>; pending: IteratorResult<Row> | Promise<IteratorResult<Row>> | undefined; constructor(bulkLoad: BulkLoad, rows: Iterable<Row> | AsyncIterable<Row>); /** * Closes the row source of a bulk load whose rows will not be read: * the `INSERT BULK` statement was rejected, the bulk load was canceled, * or the connection is no longer logged in. Best effort: a read still * pending in the source cannot be interrupted, and a close that fails * has nothing left to report to. */ close(): void; [Symbol.asyncIterator](): AsyncGenerator<Buffer<ArrayBufferLike>, void, unknown>; toString(indent?: string): string; }