jdb-lite
Version:
A lightweight schema-based JSON database library with validation
33 lines • 1 kB
TypeScript
import { SchemaDefinition, SchemaOptions } from './types';
export interface VirtualType {
get(fn: Function): VirtualType;
set(fn: Function): VirtualType;
}
export declare class Schema<T = any> {
definition: SchemaDefinition;
options: SchemaOptions;
methods: {
[key: string]: Function;
};
statics: {
[key: string]: Function;
};
private virtuals;
private preHooks;
private postHooks;
private indexes;
constructor(definition: SchemaDefinition, options?: SchemaOptions);
add(obj: SchemaDefinition): void;
pre(method: string, fn: Function): void;
post(method: string, fn: Function): void;
virtual(name: string): VirtualType;
index(fields: {
[key: string]: 1 | -1;
}): void;
plugin(fn: Function, options?: any): void;
validate(doc: any): string[];
private validateType;
getPreHooks(method: string): Function[];
getPostHooks(method: string): Function[];
}
//# sourceMappingURL=schema.d.ts.map