UNPKG

@restorecommerce/chassis-srv

Version:

Restore Commerce microservice chassis

115 lines 4.37 kB
import { Database } from 'arangojs'; import { DatabaseProvider } from '../../index.js'; import { ArangoDocument, CustomQuery, ViewAnalyzerOptions, ViewMap } from './interface.js'; import { type Logger } from '@restorecommerce/logger'; /** * ArangoDB database provider. */ export declare class Arango implements DatabaseProvider { readonly db: Database; readonly logger?: Logger; readonly customQueries: Map<string, CustomQuery>; readonly collectionNameAnalyzerMap: Map<string, ViewMap>; /** * * @param {Object} conn Arangojs database connection. */ constructor(db: Database, logger?: Logger); /** * Find documents based on filter. * * @param {String} collectionName Collection name * @param {Object} filter Key, value Object * @param {Object} options options.limit, options.offset * @return {Promise<any>} Promise for list of found documents. */ find(collectionName: string, filter?: any, options?: any): Promise<any>; /** * Find documents by id (_key). * * @param {String} collection Collection name * @param {String|array.String} ids A single ID or multiple IDs. * @return {Promise<any>} A list of found documents. */ findByID(collectionName: string, ids: string | string[]): Promise<any>; /** * retreive the documents including the document handlers (_key, _id and _rev). * * @param {String} collectionName Collection name * @param {any} collection Collection Object * @param {ArangoDocument | ArangoDocument[]} documents list of documents * @param {string[]} idsArray list of document ids * @returns {Promise<ArangoDocument[]>} A list of documents including the document handlers */ getDocumentHandlers(collectionName: string, collection: any, documents: ArangoDocument | ArangoDocument[], idsArray?: string[]): Promise<ArangoDocument[]>; /** * Find documents by filter and updates them with document. * * @param {String} collection Collection name * @param {Object} updateDocuments List of documents to update */ update(collectionName: string, updateDocuments: any): Promise<any>; /** * Find each document based on it's key and update it. * If the document does not exist it will be created. * * @param {String} collectionName Collection name * @param {Object|Array.Object} documents */ upsert(collectionName: string, documents: any): Promise<any>; /** * Delete all documents with provided identifiers ids. * * @param {String} collection Collection name * @param {Object} ids list of document identifiers * @return {Promise<any>} delete response */ delete(collectionName: string, ids: string[]): Promise<any>; /** * Count all documents selected by filter. * * @param {String} collection Collection name * @param {Object} filter */ count(collectionName: string, filter: any): Promise<any>; /** * When calling without a collection name, * delete all documents in all collections in the database. * When providing a collection name, * delete all documents in specified collection in the database. * @param [string] collection Collection name. */ truncate(collection: string): Promise<any>; /** * Drop view * @param string[] list of view names. */ dropView(viewName: string[]): Promise<any>; /** * Delete Analyzer * @param string[] list of analyzer names. */ deleteAnalyzer(analyzerName: string[]): Promise<any>; /** * Insert documents into database. * * @param {String} collection Collection name * @param {Object|array.Object} documents A single or multiple documents. */ insert(collectionName: string, documents: any): Promise<any>; /** * Registers a custom AQL query. * * @param script * @param name */ registerCustomQuery(name: string, script: string, type: 'filter' | 'query'): void; /** * Unregisters a custom query. * @param name */ unregisterCustomQuery(name: string): void; listCustomQueries(): Array<any>; createAnalyzerAndView(viewConfig: ViewAnalyzerOptions, collectionName: string): Promise<void>; } //# sourceMappingURL=base.d.ts.map