import Node from './Node'; export declare type CountCallback = (err, count?: number) => void; export declare type NodeCallback = (err, node?: Node) => void; export declare type NodesCallback = (err, nodes?: Node[]) => void; /** * Database Class. Interface to Node Embedded Database (NeDB). * * @class Database * @memberof jibo.kb * @param {string} filename Full path filename to NeDB file. * @internal */ export default class Database { filename: string; nodes: any; constructor(filename: string); /** Attach to the NeDB filename given in constructor. File is * compacted upon opening, or created if it doesn't exist. * * @method jibo.kb.Database#init * @param {Function} callback Called when done compacting/creating/attaching. * @internal */ init(callback: CountCallback): void; /** Load node of given id. Returns null (via callback) if * not found. * * @method jibo.kb.Database#load * @param {string} id ID of node to load. * @param {Function} callback Called with (err, node). Node (and err) is null if not found. * @internal */ load(id: string, callback: NodeCallback): void; /** Load one node of a given type. Used to find the 'root' node. * * @method jibo.kb.Database#loadNodeOfType * @param {string} nodeType Node type to load. * @param {Function} callback Called with (err, node). Node (and err) is null if not found. * @internal */ loadNodeOfType(nodeType: string, callback: NodeCallback): void; /** Load every node (in this kb slice) of a given type. * * @method jibo.kb.Database#loadNodesOfType * @param {string} nodeType Node type to load. * @param {Function} callback Called with (err, nodes) where nodes * is an array of the found nodes. * @internal */ loadNodesOfType(nodeType: string, callback: NodesCallback): void; /** Save a given node. * * @method jibo.kb.Database#save * @param {jibo.kb.Node} node The node to be saved. * @param {Function} callback Called with (err, node) when finished. * @internal */ save(node: Node, callback: NodeCallback): void; /** Remove a node from this kb slice. * * @method jibo.kb.Database#remove * @param {string|jibo.kb.Node} idOrNode Id string or Node object to be removed. * @param {Function} callback Called with (err, numRemoved) when finished. * @internal */ remove(idOrNode: string | Node, callback: CountCallback): void; /** Convert an idOrNode parameter to an id if it's a node. * * @method jibo.kb.Database#_toId * @param {string|jibo.kb.Node} ID string, or node with an ._id property. * @returns {string} ID * @private * @internal */ private _toId(idOrNode); }