@dnax/core 0.19.2 → 0.19.3
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 +21 -17
- package/package.json +1 -1
package/lib/collection.ts
CHANGED
|
@@ -64,6 +64,8 @@ async function syncCollectionDatabase() {
|
|
|
64
64
|
?.listCollections()
|
|
65
65
|
.toArray();
|
|
66
66
|
|
|
67
|
+
//t.database.db.
|
|
68
|
+
|
|
67
69
|
if (t.database.driver == "mongodb") {
|
|
68
70
|
const collections: Collection[] | undefined = Cfg.collections?.filter(
|
|
69
71
|
(cn) => cn.tenant_id == t.id
|
|
@@ -92,13 +94,29 @@ async function syncCollectionDatabase() {
|
|
|
92
94
|
await t.database.db?.createCollection(c.slug);
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
// suppression d'index
|
|
98
|
+
c?.fields?.map((f) => {
|
|
99
|
+
if (f?.unique === false) {
|
|
100
|
+
let keyToremove = f?.name + "_1";
|
|
101
|
+
// console.log('keyToremove :: ',keyToremove)
|
|
102
|
+
t.database.db
|
|
103
|
+
?.collection(c.slug)
|
|
104
|
+
.dropIndex(keyToremove)
|
|
105
|
+
.catch((err) => {
|
|
106
|
+
// console.error(err);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
95
111
|
// suppression auto Removes des indexes
|
|
96
112
|
if (c?.autoRemoveIndexes?.length) {
|
|
97
113
|
for await (let index of c?.autoRemoveIndexes || []) {
|
|
98
114
|
await t.database?.db
|
|
99
115
|
?.collection(c.slug)
|
|
100
116
|
.dropIndex(index)
|
|
101
|
-
.catch((err) => {
|
|
117
|
+
.catch((err) => {
|
|
118
|
+
// console.error(err?.message);
|
|
119
|
+
});
|
|
102
120
|
}
|
|
103
121
|
}
|
|
104
122
|
|
|
@@ -106,11 +124,9 @@ async function syncCollectionDatabase() {
|
|
|
106
124
|
?.collection(c.slug)
|
|
107
125
|
.indexes()
|
|
108
126
|
.catch((err) => {
|
|
109
|
-
console.error(err?.message);
|
|
127
|
+
// console.error(err?.message);
|
|
110
128
|
});
|
|
111
129
|
|
|
112
|
-
// console.log('Allindex',allIndexes)
|
|
113
|
-
|
|
114
130
|
for await (let dbIndex of allIndexes || []) {
|
|
115
131
|
// creation des indexes createdAt / updatedAt
|
|
116
132
|
if (!dbIndex?.key?.createdAt && !dbIndex?.key?.updatedAt) {
|
|
@@ -148,18 +164,6 @@ async function syncCollectionDatabase() {
|
|
|
148
164
|
}
|
|
149
165
|
});
|
|
150
166
|
|
|
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
|
-
|
|
163
167
|
// 3- Creation des indexes par indexes array
|
|
164
168
|
for await (let index of c?.indexes || []) {
|
|
165
169
|
let indexHasAlready = allIndexes?.find((el) => {
|
|
@@ -174,7 +178,7 @@ async function syncCollectionDatabase() {
|
|
|
174
178
|
?.collection(c.slug)
|
|
175
179
|
.dropIndex(indexHasAlready?.name)
|
|
176
180
|
.catch((err) => {
|
|
177
|
-
console.error(err?.message);
|
|
181
|
+
// console.error(err?.message);
|
|
178
182
|
});
|
|
179
183
|
}
|
|
180
184
|
|