@goatlab/fluent-firebase 0.7.7 → 0.7.8
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/FirebaseConnector.d.ts +1 -1
- package/dist/FirebaseConnector.js +8 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/CHANGELOG.md +0 -1020
- package/changelog-template.hbs +0 -52
- package/dist/test/car.repository.d.ts +0 -8
- package/dist/test/car.repository.js +0 -21
- package/dist/test/goat.repository.d.ts +0 -5
- package/dist/test/goat.repository.js +0 -14
- package/dist/test/roles.repository.d.ts +0 -8
- package/dist/test/roles.repository.js +0 -21
- package/dist/test/roles_user.repository.d.ts +0 -6
- package/dist/test/roles_user.repository.js +0 -15
- package/dist/test/typeOrm.repository.d.ts +0 -5
- package/dist/test/typeOrm.repository.js +0 -15
- package/dist/test/user.repository.d.ts +0 -10
- package/dist/test/user.repository.js +0 -29
|
@@ -15,7 +15,7 @@ export declare class FirebaseConnector<ModelDTO = AnyObject, InputDTO = ModelDTO
|
|
|
15
15
|
constructor({ entity, inputSchema, outputSchema }: FirebaseConnectorParams<InputDTO, OutputDTO>);
|
|
16
16
|
insert(data: InputDTO): Promise<OutputDTO>;
|
|
17
17
|
insertMany(data: InputDTO[]): Promise<OutputDTO[]>;
|
|
18
|
-
findMany<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO
|
|
18
|
+
findMany<T extends FluentQuery<ModelDTO>>(query?: T): Promise<QueryOutput<T, ModelDTO>[]>;
|
|
19
19
|
updateById(id: string, data: InputDTO): Promise<OutputDTO>;
|
|
20
20
|
replaceById(id: string, data: InputDTO): Promise<OutputDTO>;
|
|
21
21
|
deleteById(id: string): Promise<string>;
|
|
@@ -39,7 +39,7 @@ class FirebaseConnector extends fluent_2.BaseConnector {
|
|
|
39
39
|
...validatedData
|
|
40
40
|
};
|
|
41
41
|
await this.collection.doc(id).set(item);
|
|
42
|
-
return this.outputSchema.parse(
|
|
42
|
+
return this.outputSchema.parse(js_utils_1.Objects.clearEmpties(js_utils_1.Objects.deleteNulls(item)));
|
|
43
43
|
}
|
|
44
44
|
async insertMany(data) {
|
|
45
45
|
const validatedData = this.inputSchema.array().parse(data);
|
|
@@ -54,7 +54,7 @@ class FirebaseConnector extends fluent_2.BaseConnector {
|
|
|
54
54
|
});
|
|
55
55
|
await batch.commit();
|
|
56
56
|
return this.outputSchema.array().parse(batchInserted.map(d => {
|
|
57
|
-
return
|
|
57
|
+
return js_utils_1.Objects.clearEmpties(js_utils_1.Objects.deleteNulls(d));
|
|
58
58
|
}));
|
|
59
59
|
}
|
|
60
60
|
async findMany(query) {
|
|
@@ -78,7 +78,7 @@ class FirebaseConnector extends fluent_2.BaseConnector {
|
|
|
78
78
|
}
|
|
79
79
|
let found = [...new Map(results.map(v => [v.id, v])).values()];
|
|
80
80
|
found.map(d => {
|
|
81
|
-
|
|
81
|
+
js_utils_1.Objects.clearEmpties(js_utils_1.Objects.deleteNulls(d));
|
|
82
82
|
});
|
|
83
83
|
if (query?.include) {
|
|
84
84
|
found = await this.loadRelatedData(found, js_utils_1.Objects.flatten(query?.include || {}));
|
|
@@ -119,7 +119,7 @@ class FirebaseConnector extends fluent_2.BaseConnector {
|
|
|
119
119
|
if (!dbResult) {
|
|
120
120
|
throw new Error(`Object not found: ${id}`);
|
|
121
121
|
}
|
|
122
|
-
return this.outputSchema?.parse(
|
|
122
|
+
return this.outputSchema?.parse(js_utils_1.Objects.clearEmpties(js_utils_1.Objects.deleteNulls(dbResult)));
|
|
123
123
|
}
|
|
124
124
|
async replaceById(id, data) {
|
|
125
125
|
const value = await this.findById(id);
|
|
@@ -144,7 +144,7 @@ class FirebaseConnector extends fluent_2.BaseConnector {
|
|
|
144
144
|
.doc(id)
|
|
145
145
|
.update(validatedData);
|
|
146
146
|
const val = await this.requireById(id);
|
|
147
|
-
return this.outputSchema.parse(
|
|
147
|
+
return this.outputSchema.parse(js_utils_1.Objects.clearEmpties(js_utils_1.Objects.deleteNulls(val)));
|
|
148
148
|
}
|
|
149
149
|
async deleteById(id) {
|
|
150
150
|
await this.collection.doc(id).delete();
|
|
@@ -262,8 +262,8 @@ class FirebaseConnector extends fluent_2.BaseConnector {
|
|
|
262
262
|
}
|
|
263
263
|
let andWhereQuery = this.collection;
|
|
264
264
|
let orWhereQueries = [];
|
|
265
|
-
const orConditions =
|
|
266
|
-
const andConditions =
|
|
265
|
+
const orConditions = (0, fluent_1.extractConditions)(where['OR']);
|
|
266
|
+
const andConditions = (0, fluent_1.extractConditions)(where['AND']);
|
|
267
267
|
const copy = js_utils_1.Objects.clone(where);
|
|
268
268
|
if (!!copy['AND']) {
|
|
269
269
|
delete copy['AND'];
|
|
@@ -271,7 +271,7 @@ class FirebaseConnector extends fluent_2.BaseConnector {
|
|
|
271
271
|
if (!!copy['OR']) {
|
|
272
272
|
delete copy['OR'];
|
|
273
273
|
}
|
|
274
|
-
const rootLevelConditions =
|
|
274
|
+
const rootLevelConditions = (0, fluent_1.extractConditions)([copy]);
|
|
275
275
|
for (const condition of andConditions) {
|
|
276
276
|
const { element, operator, value } = condition;
|
|
277
277
|
switch (operator) {
|