@dnax/core 0.14.9 → 0.15.1
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/lib/collection.ts +9 -19
- package/package.json +1 -1
- package/types/index.ts +2 -1
package/lib/collection.ts
CHANGED
|
@@ -92,7 +92,6 @@ async function syncCollectionDatabase() {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// suppression auto Removes des indexes
|
|
95
|
-
|
|
96
95
|
if (c?.autoRemoveIndexes?.length && c?.autoRemoveIndexes) {
|
|
97
96
|
for await (let index of c?.autoRemoveIndexes || []) {
|
|
98
97
|
await t.database?.db
|
|
@@ -112,33 +111,24 @@ async function syncCollectionDatabase() {
|
|
|
112
111
|
// console.log('Allindex',allIndexes)
|
|
113
112
|
|
|
114
113
|
for await (let dbIndex of allIndexes || []) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
// creation des indexes createdAt / updatedAt
|
|
115
|
+
if (!dbIndex?.key?.createdAt && !dbIndex?.key?.updatedAt) {
|
|
116
|
+
await t.database.db
|
|
117
|
+
?.collection(c.slug)
|
|
118
|
+
.createIndex(["createdAt", "updatedAt"])
|
|
119
|
+
.then((e) => {})
|
|
120
|
+
.catch((err) => {});
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
//console.log(t.database.db);
|
|
125
|
-
// 1- Creation des indexes normal
|
|
126
|
-
await t.database.db
|
|
127
|
-
?.collection(c.slug)
|
|
128
|
-
.createIndex(["createdAt", "updatedAt"])
|
|
129
|
-
.then((e) => {})
|
|
130
|
-
.catch((err) => {
|
|
131
|
-
console.error(err?.message);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
124
|
// 2- Creation des indexes par champs unique/random
|
|
135
|
-
|
|
136
125
|
c.fields?.map((f) => {
|
|
137
126
|
if (f?.index) {
|
|
138
127
|
t.database.db?.collection(c.slug).createIndex({
|
|
139
128
|
[f.name]: f.index == true ? 1 : f.index,
|
|
140
129
|
});
|
|
141
130
|
}
|
|
131
|
+
|
|
142
132
|
if (f?.unique || f?.random) {
|
|
143
133
|
t.database.db
|
|
144
134
|
?.collection(c.slug)
|
|
@@ -152,7 +142,7 @@ async function syncCollectionDatabase() {
|
|
|
152
142
|
}
|
|
153
143
|
)
|
|
154
144
|
.catch((err) => {
|
|
155
|
-
console.error(err);
|
|
145
|
+
//console.error(err);
|
|
156
146
|
});
|
|
157
147
|
}
|
|
158
148
|
});
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -102,7 +102,7 @@ export type Field = {
|
|
|
102
102
|
nullable?: boolean;
|
|
103
103
|
defaultValue?: any;
|
|
104
104
|
unique?: boolean;
|
|
105
|
-
index?: boolean | "text" | "2dsphere";
|
|
105
|
+
index?: boolean | "text" | "2dsphere" | "2d" | -1 | 1;
|
|
106
106
|
description?: string;
|
|
107
107
|
relation?: {
|
|
108
108
|
to: string; // collection name
|
|
@@ -296,6 +296,7 @@ export type Collection = {
|
|
|
296
296
|
[key: string]: any;
|
|
297
297
|
unique?: Boolean;
|
|
298
298
|
expireAfterSeconds?: number;
|
|
299
|
+
partialFilterExpression?: any;
|
|
299
300
|
}>;
|
|
300
301
|
autoRemoveIndexes?: Array<{
|
|
301
302
|
[key: string]: any;
|