UNPKG

2.48 kBTypeScriptView Raw
1import { AdapterBase, AdapterParams, AdapterQuery, AdapterServiceOptions, PaginationOptions } from "@feathersjs/adapter-commons";
2import { Id, NullableId, Paginated } from "@feathersjs/feathers";
3import NeDB from "@seald-io/nedb";
4export interface NeDBAdapterOptions extends AdapterServiceOptions {
5 Model: NeDB;
6}
7export interface NeDBAdapterParams<Q = AdapterQuery> extends AdapterParams<Q, Partial<NeDBAdapterOptions>> {
8 nedb?: {
9 upsert: boolean;
10 };
11}
12export declare class NeDbAdapter<Result extends Record<string, any>, Data extends Record<string, any> = Partial<Result>, ServiceParams extends NeDBAdapterParams<any> = NeDBAdapterParams, PatchData = Partial<Data>> extends AdapterBase<Result, Data, PatchData, ServiceParams, NeDBAdapterOptions> {
13 constructor(options: NeDBAdapterOptions);
14 getSelect(select: string[]): any;
15 filterQuery(id: NullableId, params: ServiceParams): {
16 filters: {
17 $select: string[];
18 $sort: {
19 [key: string]: 1 | -1;
20 };
21 $limit: number;
22 $skip: number;
23 };
24 query: {
25 [key: string]: any;
26 };
27 };
28 _findOrGet(id: NullableId, params: ServiceParams): Promise<Result | Paginated<Result> | Result[]>;
29 normalizeId<D>(id: NullableId, data: D): D;
30 _find(params?: ServiceParams & {
31 paginate?: PaginationOptions;
32 }): Promise<Paginated<Result>>;
33 _find(params?: ServiceParams & {
34 paginate: false;
35 }): Promise<Result[]>;
36 _find(params?: ServiceParams): Promise<Paginated<Result> | Result[]>;
37 _get(id: NullableId, params?: ServiceParams): Promise<Result>;
38 _create(data: Data, params?: ServiceParams): Promise<Result>;
39 _create(data: Data[], params?: ServiceParams): Promise<Result[]>;
40 _create(data: Data | Data[], _params?: ServiceParams): Promise<Result | Result[]>;
41 _update(id: Id, data: Data, params?: ServiceParams): Promise<Result>;
42 _patch(id: null, data: PatchData | Partial<Result>, params?: ServiceParams): Promise<Result[]>;
43 _patch(id: Id, data: PatchData | Partial<Result>, params?: ServiceParams): Promise<Result>;
44 _patch(id: NullableId, data: PatchData | Partial<Result>, _params?: ServiceParams): Promise<Result | Result[]>;
45 _remove(id: null, params?: ServiceParams): Promise<Result[]>;
46 _remove(id: Id, params?: ServiceParams): Promise<Result>;
47 _remove(id: NullableId, _params?: ServiceParams): Promise<Result | Result[]>;
48}