@dnax/core 0.19.1 → 0.19.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.
- package/lib/collection.ts +14 -1
- package/package.json +1 -1
package/lib/collection.ts
CHANGED
|
@@ -71,6 +71,7 @@ async function syncCollectionDatabase() {
|
|
|
71
71
|
|
|
72
72
|
if (collections?.length) {
|
|
73
73
|
for await (let c of collections) {
|
|
74
|
+
// boucle sur les collections
|
|
74
75
|
//console.log(c?.slug,c.init)
|
|
75
76
|
if (c?.init && typeof c?.init == "function") {
|
|
76
77
|
await c?.init({
|
|
@@ -92,7 +93,7 @@ async function syncCollectionDatabase() {
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
// suppression auto Removes des indexes
|
|
95
|
-
if (c?.autoRemoveIndexes?.length
|
|
96
|
+
if (c?.autoRemoveIndexes?.length) {
|
|
96
97
|
for await (let index of c?.autoRemoveIndexes || []) {
|
|
97
98
|
await t.database?.db
|
|
98
99
|
?.collection(c.slug)
|
|
@@ -147,6 +148,18 @@ async function syncCollectionDatabase() {
|
|
|
147
148
|
}
|
|
148
149
|
});
|
|
149
150
|
|
|
151
|
+
// suppression d'index
|
|
152
|
+
c?.fields?.map((f) => {
|
|
153
|
+
if (f?.unique === false) {
|
|
154
|
+
t.database.db
|
|
155
|
+
?.collection(c.slug)
|
|
156
|
+
.dropIndex(f.name)
|
|
157
|
+
.catch((err) => {
|
|
158
|
+
//console.error(err);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
150
163
|
// 3- Creation des indexes par indexes array
|
|
151
164
|
for await (let index of c?.indexes || []) {
|
|
152
165
|
let indexHasAlready = allIndexes?.find((el) => {
|