@dnax/core 0.4.2 → 0.4.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/driver/mongo/rest.ts +1 -1
- package/lib/collection.ts +18 -1
- package/package.json +1 -1
package/driver/mongo/rest.ts
CHANGED
package/lib/collection.ts
CHANGED
|
@@ -93,18 +93,22 @@ async function syncCollectionDatabase() {
|
|
|
93
93
|
|
|
94
94
|
var allIndexes = await t.database.db?.collection(c.slug).indexes();
|
|
95
95
|
|
|
96
|
+
// console.log('Allindex',allIndexes)
|
|
97
|
+
|
|
96
98
|
for await (let dbIndex of allIndexes || []) {
|
|
97
99
|
if (
|
|
98
100
|
dbIndex?.key?.createdAt ||
|
|
99
101
|
dbIndex?.key?.updatedAt ||
|
|
100
102
|
dbIndex?.key?._id
|
|
101
103
|
) {
|
|
102
|
-
|
|
104
|
+
continue;
|
|
103
105
|
}
|
|
104
106
|
|
|
107
|
+
// creation des indexes si n'existe in remote
|
|
105
108
|
let findexIndexKey = c.fields?.map(
|
|
106
109
|
(field) => dbIndex.key[field.name]
|
|
107
110
|
);
|
|
111
|
+
|
|
108
112
|
if (!findexIndexKey)
|
|
109
113
|
await t.database.db
|
|
110
114
|
?.collection(c?.slug)
|
|
@@ -118,6 +122,19 @@ async function syncCollectionDatabase() {
|
|
|
118
122
|
.createIndex(["createdAt", "updatedAt"])
|
|
119
123
|
.then((e) => {});
|
|
120
124
|
|
|
125
|
+
// 3- suppression des indexes
|
|
126
|
+
c.fields?.map((f) => {
|
|
127
|
+
if (!f?.unique && allIndexes?.find((e) => e?.key[f.name])) {
|
|
128
|
+
//@ts-expect-error
|
|
129
|
+
t.database.db
|
|
130
|
+
?.collection(c.slug)
|
|
131
|
+
.dropIndex({
|
|
132
|
+
[f.name]: 1,
|
|
133
|
+
})
|
|
134
|
+
.catch();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
121
138
|
// 2- Creation des indexes par champs unique/random
|
|
122
139
|
|
|
123
140
|
c.fields?.map((f) => {
|