@goatlab/fluent-pouchdb 0.7.10 → 0.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PouchDBConnector.d.ts +115 -0
- package/dist/PouchDBConnector.js +604 -0
- package/dist/PouchDBConnector.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/test/entities/advanced.entity.d.ts +79 -0
- package/dist/test/entities/advanced.entity.js +61 -0
- package/dist/test/entities/advanced.entity.js.map +1 -0
- package/dist/test/entities/goat.entity.d.ts +155 -0
- package/dist/test/entities/goat.entity.js +89 -0
- package/dist/test/entities/goat.entity.js.map +1 -0
- package/dist/test/pouchdb.repository.factory.d.ts +8 -0
- package/dist/test/pouchdb.repository.factory.js +32 -0
- package/dist/test/pouchdb.repository.factory.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +9 -7
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { AnyObject } from '@goatlab/js-utils';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export interface PouchDBConnectorParams<Input, Output> {
|
|
4
|
+
entity: any;
|
|
5
|
+
dataSource: PouchDB.Database;
|
|
6
|
+
inputSchema: z.ZodType<Input>;
|
|
7
|
+
outputSchema?: z.ZodType<Output>;
|
|
8
|
+
}
|
|
9
|
+
interface FluentQuery<T> {
|
|
10
|
+
where?: any;
|
|
11
|
+
select?: any;
|
|
12
|
+
include?: any;
|
|
13
|
+
orderBy?: any[];
|
|
14
|
+
limit?: number;
|
|
15
|
+
offset?: number;
|
|
16
|
+
paginated?: {
|
|
17
|
+
page: number;
|
|
18
|
+
perPage: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface FindByIdFilter<T> {
|
|
22
|
+
select?: any;
|
|
23
|
+
include?: any;
|
|
24
|
+
limit?: number;
|
|
25
|
+
}
|
|
26
|
+
interface LoadedResult<T> {
|
|
27
|
+
}
|
|
28
|
+
type QueryOutput<T, U> = any;
|
|
29
|
+
interface FluentConnectorInterface<ModelDTO, InputDTO, OutputDTO> {
|
|
30
|
+
insert(data: InputDTO): Promise<OutputDTO>;
|
|
31
|
+
insertMany(data: InputDTO[]): Promise<OutputDTO[]>;
|
|
32
|
+
updateById(id: string, data: Partial<InputDTO>): Promise<OutputDTO>;
|
|
33
|
+
replaceById(id: string, data: Partial<InputDTO>): Promise<OutputDTO>;
|
|
34
|
+
deleteById(id: string): Promise<string>;
|
|
35
|
+
findMany<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO>[]>;
|
|
36
|
+
findFirst<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO> | null>;
|
|
37
|
+
findByIds<T extends FindByIdFilter<ModelDTO>>(ids: string[], q?: T): Promise<QueryOutput<T, ModelDTO>[]>;
|
|
38
|
+
requireById(id: string, q?: FindByIdFilter<ModelDTO>): Promise<QueryOutput<FindByIdFilter<ModelDTO>, ModelDTO>>;
|
|
39
|
+
requireFirst<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO>>;
|
|
40
|
+
pluck(path: any, query?: FluentQuery<ModelDTO>): Promise<any[]>;
|
|
41
|
+
clear(): Promise<boolean>;
|
|
42
|
+
}
|
|
43
|
+
declare abstract class BaseConnector<ModelDTO, InputDTO, OutputDTO> {
|
|
44
|
+
protected outputKeys: string[];
|
|
45
|
+
protected modelRelations: any[];
|
|
46
|
+
isMongoDB: boolean;
|
|
47
|
+
protected relationQuery?: any;
|
|
48
|
+
findFirst<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO> | null>;
|
|
49
|
+
requireById(id: string, q?: FindByIdFilter<ModelDTO>): Promise<QueryOutput<FindByIdFilter<ModelDTO>, ModelDTO>>;
|
|
50
|
+
requireFirst<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO>>;
|
|
51
|
+
findByIds<T extends FindByIdFilter<ModelDTO>>(ids: string[], q?: T): Promise<QueryOutput<T, ModelDTO>[]>;
|
|
52
|
+
setRelatedQuery(query: any): void;
|
|
53
|
+
abstract insert(data: InputDTO): Promise<OutputDTO>;
|
|
54
|
+
abstract insertMany(data: InputDTO[]): Promise<OutputDTO[]>;
|
|
55
|
+
abstract updateById(id: string, data: Partial<InputDTO>): Promise<OutputDTO>;
|
|
56
|
+
abstract replaceById(id: string, data: Partial<InputDTO>): Promise<OutputDTO>;
|
|
57
|
+
abstract deleteById(id: string): Promise<string>;
|
|
58
|
+
abstract findMany<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO>[]>;
|
|
59
|
+
abstract pluck(path: any, query?: FluentQuery<ModelDTO>): Promise<any[]>;
|
|
60
|
+
abstract clear(): Promise<boolean>;
|
|
61
|
+
}
|
|
62
|
+
export declare class PouchDBConnector<ModelDTO = AnyObject, InputDTO = ModelDTO, OutputDTO = ModelDTO> extends BaseConnector<ModelDTO, InputDTO, OutputDTO> implements FluentConnectorInterface<ModelDTO, InputDTO, OutputDTO> {
|
|
63
|
+
private readonly dataSource;
|
|
64
|
+
private readonly inputSchema;
|
|
65
|
+
private readonly outputSchema;
|
|
66
|
+
private readonly entity;
|
|
67
|
+
constructor({ entity, dataSource, inputSchema, outputSchema }: PouchDBConnectorParams<InputDTO, OutputDTO>);
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param data
|
|
71
|
+
*/
|
|
72
|
+
insert(data: InputDTO): Promise<OutputDTO>;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param data
|
|
76
|
+
*/
|
|
77
|
+
insertMany(data: InputDTO[]): Promise<OutputDTO[]>;
|
|
78
|
+
/**
|
|
79
|
+
* PATCH operation
|
|
80
|
+
* @param data
|
|
81
|
+
*/
|
|
82
|
+
updateById(id: string, data: Partial<InputDTO>): Promise<OutputDTO>;
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* PUT operation. All fields not included in the data
|
|
86
|
+
* param will be set to null
|
|
87
|
+
*
|
|
88
|
+
* @param id
|
|
89
|
+
* @param data
|
|
90
|
+
*/
|
|
91
|
+
replaceById(id: string, data: Partial<InputDTO>): Promise<OutputDTO>;
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* Returns the PouchDB Database, you can use it
|
|
95
|
+
* form more complex queries
|
|
96
|
+
*
|
|
97
|
+
* @param query
|
|
98
|
+
*/
|
|
99
|
+
raw(): PouchDB.Database;
|
|
100
|
+
findMany<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO>[]>;
|
|
101
|
+
getPouchDBWhere(where?: FluentQuery<ModelDTO>['where']): PouchDB.Find.FindRequest<any>;
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @param id
|
|
105
|
+
*/
|
|
106
|
+
deleteById(id: string): Promise<string>;
|
|
107
|
+
loadFirst(query?: FluentQuery<ModelDTO>): PouchDBConnector<ModelDTO, InputDTO, OutputDTO>;
|
|
108
|
+
loadById(id: string): LoadedResult<this>;
|
|
109
|
+
protected clone(): any;
|
|
110
|
+
findById<T extends FindByIdFilter<ModelDTO>>(id: string, q?: T): Promise<QueryOutput<T, ModelDTO> | null>;
|
|
111
|
+
findByIds<T extends FindByIdFilter<ModelDTO>>(ids: string[], q?: T): Promise<QueryOutput<T, ModelDTO>[]>;
|
|
112
|
+
pluck(path: any, query?: FluentQuery<ModelDTO>): Promise<any[]>;
|
|
113
|
+
clear(): Promise<boolean>;
|
|
114
|
+
}
|
|
115
|
+
export {};
|