import { ResultAsync } from "neverthrow"; import { IDendronError } from "../error"; import { Disposable, RespV3 } from "../types"; /** * Interface responsible for interacting with data store */ export interface IDataStore extends Disposable { /** * Get data by key * If key is not found, return error. * * @param key: key of data * @return data */ get(key: K): Promise>; /** * Find data by criteria. If no criteria is set, return empty array. * If multiple criterias are set, find data that matches all criteria * * @param opts: data criteria * @return List of data that matches criteria */ find(opts: any): Promise>; /** * Write data to store for given key, overriding existing data if it already exists * * @param key: key of data to write * @param data: data to write * @return original key */ write(key: K, data: V): Promise>; /** * Delete data from store for given key. * If key does not exist, do nothing. * * @param key: key of data to delete * @return original key */ delete(key: K): Promise>; /** * Query data by criteria. Differs from find in that this supports full-text fuzzy search * on note properties. * TODO: consider replacing find altogether * * @param opts: data criteria * @return List of data that matches criteria */ query(opts: any): ResultAsync; }