nosqlax
Version:
NoSQLax is a lightweight JavaScript library designed to simplify and streamline CRUD operations with CouchDB. NoSQLax provides a unified and intuitive repository pattern to handle your data effortlessly.
30 lines (29 loc) • 1.25 kB
TypeScript
import Nano, { DocumentScope, MangoQuery, MangoSelector } from "nano";
import BaseEntity from './BaseEntity';
type MangoOptions = Omit<MangoQuery, 'selector'>;
type EntityClass = {
fieldMap: Record<string, string>;
new (data: Record<string, any>): BaseEntity;
schemaOrSchemaId: string | object;
type: string;
[key: string]: any;
};
declare abstract class CouchRepository {
private connection;
private validator;
private entityClass;
private fieldMap;
constructor(nanoConnection: DocumentScope<Nano.MaybeDocument>, ajvOptions: any, entityClass: EntityClass);
find(id: string): Promise<BaseEntity>;
findOne(selector: MangoSelector, options?: MangoOptions): Promise<BaseEntity>;
findMany(selector: MangoSelector, options?: MangoOptions): Promise<BaseEntity[]>;
findAll(options?: MangoOptions): Promise<BaseEntity[]>;
create(data: EntityClass): Promise<BaseEntity>;
update(id: string, data: EntityClass): Promise<BaseEntity>;
delete(id: string): Promise<{
message: string;
}>;
get dbConnection(): Nano.DocumentScope<Nano.MaybeDocument>;
static getFieldNameFromFieldMap(fieldMap: Record<string, string>, entityAttr: string): string;
}
export default CouchRepository;