UNPKG

docmenager

Version:
47 lines (41 loc) 2.19 kB
declare module 'docmenager' { export class DataBase { /** * Builds the directory for documents * @param dir The directory where .json documents are stored */ constructor(dir: String) /** * Initializes all the documents. This method must be used always before starting to use the database * @returns {Promise<Object[]>} An array of every documents stored */ public init(): Promise<Object[]> /** * Creates a document containing the object in the argument * @param {object} [document] An object that will be converted into JSON and stored in the directory * @returns {Promise<Object>} The document created */ public createDoc(document: object): Promise<Object> /** * Finds one document * @param {object} [document] An object containing one or more elements that will be the key to find another document * @returns {Promise<Object>} The object found */ public findOne(document: object): Promise<Object> /** * Deletes one document * @param {object} [document] An object containing one or more elements that will be the key to find and delete another document * @returns {Promise<void>} Deletes the document and doesn't return anything */ public deleteDoc(document: object): Promise<void> /** * * @param {object} [document] An object containing one or more elements that will be the key to find another document * @param {object} [toUpdate] An object containing one or more elements that will replace the previous values of the document found * @param {object} [options] The options for the updating * @property newItem selects if any keys from toUpdate must be created in the old document * @property newDoc selects if another document must be created, but leaves the old document the same */ public updateOne(document: object, toUpdate: object, options: {newItem: boolean, newDoc: boolean}): Promise<Object> } }