docorm
Version:
Persistence layer with ORM features for JSON documents
57 lines • 2.22 kB
TypeScript
/// <reference types="node" resolution-mode="require"/>
import QueryStream from 'pg-query-stream';
import type { PropertyPath } from 'schema-fun';
import { Transform } from 'stream';
import { Entity, EntityType, Id } from '../entity-types.js';
import { QueryClause, QueryOrder } from '../queries.js';
export type FetchResults = Entity[];
export interface FetchResultsStream {
run: () => Promise<QueryStream>;
stream: Transform;
}
export declare function fetchResultsIsArray(x: FetchResults | FetchResultsStream): x is FetchResults;
export declare function fetchResultsIsStream(x: FetchResults | FetchResultsStream): x is FetchResultsStream;
interface CountOptions {
client?: any;
}
/** Options for calls to fetch, as passed by the caller. */
interface FetchOptionsInput {
client?: any;
order?: QueryOrder;
offset?: number;
limit?: number;
stream?: any;
propertyBlacklist?: PropertyPath[];
idsOnly?: boolean;
}
declare const makeRawDao: (entityType: EntityType) => {
entityType: EntityType;
count: (query?: QueryClause, options?: CountOptions) => Promise<any>;
fetch: (query?: QueryClause, options?: FetchOptionsInput) => Promise<FetchResults | FetchResultsStream>;
fetchWithSql: (whereClauseSql?: string | null, whereClauseParameters?: never[], options?: FetchOptionsInput) => Promise<any[]>;
fetchAll: (options?: FetchOptionsInput) => Promise<any[] | {
run: () => Promise<QueryStream>;
stream: Transform;
}>;
fetchById: (ids: Id[], options?: FetchOptionsInput) => Promise<any[]>;
fetchOneById: (id: Id, options?: {
client?: any;
propertyBlacklist?: PropertyPath[];
}) => Promise<any>;
insertMultipleItems: (items: any[]) => Promise<void>;
insert: (item: any, options?: {
client?: any;
}) => Promise<any>;
update: (item: any, options?: {
client?: any;
}) => Promise<any>;
updateMultipleItems: (items: any[]) => Promise<void>;
deleteOneById: (id: Id, options?: {
client?: any;
}) => Promise<void>;
delete: (query?: QueryClause, options?: {
client?: any;
}) => Promise<void>;
};
export default makeRawDao;
//# sourceMappingURL=raw-dao.d.ts.map