docorm
Version:
Persistence layer with ORM features for JSON documents
36 lines • 1.54 kB
TypeScript
/**
* Data Access Objects for PostgreSQL
*
* @module lib/db/postgresql/dao
*/
import { Collection, EntityType } from './entity-types.js';
export type Dao = any;
interface DaoOptionsInput {
/**
* An array of ancestor collections, with the immediate parent collection last. When managing items that do not
* belong to a parent collection, this is empty.
*/
parentCollections?: Collection[];
/** An array of DAOs for the ancestor objects. This should have the same length as parentCollections. */
parentDaos?: Dao[];
/** The draft batch ID, if any. */
draftBatchId?: string;
}
/**
* Create a Data Access Object (DAO).
*
* The new DAO's behavior is determined by several parameters:
* - The entity type defines the storage table, schema, and validation behaviors.
* - parentCollections is an array of ancestor collections. TODO Document the collection data type. If present, then
* this DAO will not read and write items using a database table but will fetch them from a parent item's collection
* and, on insert or update, will save the parent item.
* - If draftBatchId is non-null, then items are written to the drafts table instead of the appropriate item storage
* table.
*
* @param entityType - The entity type of the items that this DAO will manage.
* @param options - Options for this DAO.
* @return {Object} A new DAO.
*/
declare const makeDao: (entityType: EntityType, options?: DaoOptionsInput) => Promise<Dao>;
export default makeDao;
//# sourceMappingURL=dao.d.ts.map