@dnax/core 0.52.3 → 0.53.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/driver/mongo/connect.ts +2 -1
- package/lib/collection.ts +43 -8
- package/package.json +1 -1
- package/types/index.ts +1 -0
package/driver/mongo/connect.ts
CHANGED
|
@@ -13,7 +13,8 @@ async function connectToMongo(t: Tenant) {
|
|
|
13
13
|
await client
|
|
14
14
|
.connect()
|
|
15
15
|
.then((e) => {
|
|
16
|
-
|
|
16
|
+
console.log("\n");
|
|
17
|
+
consola.success(`DB connected : [${t.id}] ✅`.green);
|
|
17
18
|
t.database.isConnected = true;
|
|
18
19
|
t.database.client = client;
|
|
19
20
|
t.database.db = client.db();
|
package/lib/collection.ts
CHANGED
|
@@ -73,19 +73,54 @@ async function syncCollectionDatabase() {
|
|
|
73
73
|
if (collections?.length) {
|
|
74
74
|
// searchEngine Section
|
|
75
75
|
if (t?.searchEngine?.meilisearch?.enabled) {
|
|
76
|
+
let allIndex_ = await t?.searchEngine?.meilisearch?.client
|
|
77
|
+
?.getIndexes()
|
|
78
|
+
.then((e) => e.results)
|
|
79
|
+
.catch((err) => []);
|
|
80
|
+
|
|
76
81
|
for await (let c of collections) {
|
|
77
82
|
if (c?.searchEngine?.meilisearch?.index) {
|
|
78
83
|
if (c?.searchEngine?.meilisearch?.dispatchAction) {
|
|
79
84
|
c.searchEngine.meilisearch.dispatchAction = "auto";
|
|
80
85
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
|
|
87
|
+
let indexExist = allIndex_?.find(
|
|
88
|
+
(index) => index?.uid == c?.searchEngine?.meilisearch?.index
|
|
89
|
+
);
|
|
90
|
+
if (!indexExist) {
|
|
91
|
+
await t.searchEngine.meilisearch.client
|
|
92
|
+
?.createIndex(c?.searchEngine?.meilisearch?.index, {
|
|
93
|
+
primaryKey:
|
|
94
|
+
c?.searchEngine?.meilisearch?.primaryKey || "_id",
|
|
95
|
+
})
|
|
96
|
+
.catch((err) => {
|
|
97
|
+
//consola.error(err?.message);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let attributes = await t?.searchEngine?.meilisearch?.client
|
|
102
|
+
?.index(c?.searchEngine?.meilisearch?.index)
|
|
103
|
+
.getFilterableAttributes()
|
|
104
|
+
.catch();
|
|
105
|
+
|
|
106
|
+
if (
|
|
107
|
+
c?.searchEngine?.meilisearch?.filterableAttributes?.length
|
|
108
|
+
) {
|
|
109
|
+
let s = false;
|
|
110
|
+
if (
|
|
111
|
+
!deepEqual(
|
|
112
|
+
attributes,
|
|
113
|
+
c?.searchEngine?.meilisearch?.filterableAttributes
|
|
114
|
+
)
|
|
115
|
+
) {
|
|
116
|
+
await t?.searchEngine?.meilisearch?.client
|
|
117
|
+
?.index(c?.searchEngine?.meilisearch?.index)
|
|
118
|
+
.updateFilterableAttributes(
|
|
119
|
+
c?.searchEngine?.meilisearch?.filterableAttributes
|
|
120
|
+
)
|
|
121
|
+
.catch();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
89
124
|
}
|
|
90
125
|
}
|
|
91
126
|
}
|
package/package.json
CHANGED