@tanglemedia/svelte-starter-directus-api 2.0.1 → 2.0.2
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.
|
@@ -14,7 +14,7 @@ export declare class DirectusApiAdapter<Schema extends SchemaShape = SchemaShape
|
|
|
14
14
|
total: number;
|
|
15
15
|
displayed: number;
|
|
16
16
|
};
|
|
17
|
-
includeTotals(collection: AllCollections<Schema>,
|
|
17
|
+
includeTotals(collection: AllCollections<Schema>, filter?: Record<string, unknown>): Promise<number | null>;
|
|
18
18
|
transformResponse<T, M extends object = AnyObject>(res: {
|
|
19
19
|
data: T;
|
|
20
20
|
meta?: AnyObject;
|
|
@@ -25,13 +25,13 @@ export class DirectusApiAdapter extends ApiAdapterAbstract {
|
|
|
25
25
|
// consider pulling count based on existing filters in order to determine pagination
|
|
26
26
|
return { total, displayed };
|
|
27
27
|
}
|
|
28
|
-
async includeTotals(collection,
|
|
28
|
+
async includeTotals(collection, filter) {
|
|
29
29
|
if (true !== this.config.configuration.includeTotals) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
const data = await this.directus.request(aggregate(collection, {
|
|
33
33
|
aggregate: { count: '*' },
|
|
34
|
-
|
|
34
|
+
query: { filter }
|
|
35
35
|
}));
|
|
36
36
|
if (data && data.length === 1) {
|
|
37
37
|
return Number(data[0].count);
|
package/package.json
CHANGED
|
@@ -65,14 +65,14 @@ export class DirectusApiAdapter<
|
|
|
65
65
|
return { total, displayed };
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
async includeTotals(collection: AllCollections<Schema>,
|
|
68
|
+
async includeTotals(collection: AllCollections<Schema>, filter?: Record<string, unknown>) {
|
|
69
69
|
if (true !== this.config.configuration.includeTotals) {
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const data = await this.directus.request(aggregate(collection, {
|
|
74
74
|
aggregate: { count: '*' },
|
|
75
|
-
|
|
75
|
+
query: { filter }
|
|
76
76
|
}));
|
|
77
77
|
|
|
78
78
|
if (data && data.length === 1) {
|
|
@@ -83,7 +83,7 @@ export class DirectusApiAdapter<
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
async transformResponse<T, M extends object = AnyObject>(
|
|
86
|
-
res: {data: T, meta?: AnyObject},
|
|
86
|
+
res: { data: T, meta?: AnyObject },
|
|
87
87
|
status: number = 200
|
|
88
88
|
): Promise<ApiResponse<T, Response, M>> {
|
|
89
89
|
return {
|