@dnax/core 0.14.8 → 0.15.0
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 +13 -20
- package/package.json +1 -1
package/lib/collection.ts
CHANGED
|
@@ -92,10 +92,12 @@ 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
|
-
await t.database?.db
|
|
97
|
+
await t.database?.db
|
|
98
|
+
?.collection(c.slug)
|
|
99
|
+
.dropIndex(index)
|
|
100
|
+
.catch((err) => {});
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
|
|
@@ -109,33 +111,24 @@ async function syncCollectionDatabase() {
|
|
|
109
111
|
// console.log('Allindex',allIndexes)
|
|
110
112
|
|
|
111
113
|
for await (let dbIndex of allIndexes || []) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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) => {});
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
//console.log(t.database.db);
|
|
122
|
-
// 1- Creation des indexes normal
|
|
123
|
-
await t.database.db
|
|
124
|
-
?.collection(c.slug)
|
|
125
|
-
.createIndex(["createdAt", "updatedAt"])
|
|
126
|
-
.then((e) => {})
|
|
127
|
-
.catch((err) => {
|
|
128
|
-
console.error(err?.message);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
124
|
// 2- Creation des indexes par champs unique/random
|
|
132
|
-
|
|
133
125
|
c.fields?.map((f) => {
|
|
134
126
|
if (f?.index) {
|
|
135
127
|
t.database.db?.collection(c.slug).createIndex({
|
|
136
128
|
[f.name]: f.index == true ? 1 : f.index,
|
|
137
129
|
});
|
|
138
130
|
}
|
|
131
|
+
|
|
139
132
|
if (f?.unique || f?.random) {
|
|
140
133
|
t.database.db
|
|
141
134
|
?.collection(c.slug)
|
|
@@ -149,7 +142,7 @@ async function syncCollectionDatabase() {
|
|
|
149
142
|
}
|
|
150
143
|
)
|
|
151
144
|
.catch((err) => {
|
|
152
|
-
console.error(err);
|
|
145
|
+
//console.error(err);
|
|
153
146
|
});
|
|
154
147
|
}
|
|
155
148
|
});
|