type Query = Record; /** * A minimal document store interface. Any datastore implementing this shape * can be used to back a {@link BridgeStore}. */ export interface Datastore { insert(newDocs: any[]): Promise; update(query: any, updateQuery: any, options?: UpdateOptions): Promise; remove(query: any, options: RemoveOptions): Promise; findOne(query: any): Promise; find(query: any): Promise; ensureIndex(options: EnsureIndexOptions): Promise; } export interface UpdateOptions { multi?: boolean; upsert?: boolean; } export interface RemoveOptions { multi?: boolean; } export interface EnsureIndexOptions { fieldName: string; unique?: boolean; sparse?: boolean; } /** * Base class for bridge stores. */ export declare class BridgeStore { readonly db: Datastore; constructor(db: Datastore); /** * INSERT a multiple documents. */ insert(objects: unknown): Promise; /** * UPSERT a single document */ upsert(query: Query, updateVals: T): Promise; /** * INSERT IF NOT EXISTS a single document */ insertIfNotExists(query: Query, insertObj: Record): Promise; /** * UPDATE a single document. If the document already exists, this will NOT update * it. */ update(query: Query, updateVals: Record): Promise; /** * DELETE multiple documents. */ delete(query: Query): Promise; /** * SELECT a single document. */ selectOne(query: Query, transformFn?: (input: T) => O): Promise; /** * SELECT a number of documents. * @param query * @param transformFn * @param defer */ select(query: Query, transformFn?: (input: T) => O): Promise; /** * Set a UNIQUE key constraint on the given field. * @param fieldName The field name. Use dot notation for nested objects. * @param sparse Allow sparse entries (undefined won't cause a key * violation). */ setUnique(fieldName: string, sparse?: boolean): Promise; /** * Convenience method to convert a document to something. * @param func The function which will be called with a single document * object. Guaranteed not to be null. * @return A `transformFn` function to pass to the standard * select/delete/upsert/etc methods. */ convertTo(func: (input: T) => O): (doc: T) => O; } export {};