@rpcbase/server 0.373.0 → 0.375.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/mongoose/index.ts +2 -0
- package/package.json +1 -1
- package/search/ensure_index.ts +9 -3
package/mongoose/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
// eslint-disable-next-line @rpcbase/lint/no-rb-restricted-imports
|
|
1
2
|
import mongoose from "mongoose"
|
|
2
3
|
import {object_id_plugin} from "./plugins/object_id_plugin"
|
|
3
4
|
import {disable_default_version_key_plugin} from "./plugins/disable_default_version_key_plugin"
|
|
4
5
|
import {disable_default_timestamps_plugin} from "./plugins/disable_default_timestamps_plugin"
|
|
5
6
|
|
|
7
|
+
|
|
6
8
|
mongoose.set("strictQuery", false)
|
|
7
9
|
|
|
8
10
|
mongoose.plugin(object_id_plugin)
|
package/package.json
CHANGED
package/search/ensure_index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import debug from "debug"
|
|
2
|
-
import {
|
|
2
|
+
import {get_client} from "./get_client"
|
|
3
|
+
|
|
3
4
|
|
|
4
5
|
const log = debug("rb:search:ensure_index")
|
|
5
6
|
|
|
@@ -12,8 +13,12 @@ export const ensure_index = async({
|
|
|
12
13
|
}) => {
|
|
13
14
|
const client = get_client()
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
try {
|
|
17
|
+
const exists = await client.indices.exists({index: index_id})
|
|
18
|
+
if (exists) return
|
|
19
|
+
} catch (err) {
|
|
20
|
+
console.log("Error checking for index existance", JSON.stringify(err, null, 2))
|
|
21
|
+
}
|
|
17
22
|
|
|
18
23
|
const res = await client.indices.create({
|
|
19
24
|
index: index_id,
|
|
@@ -29,3 +34,4 @@ export const ensure_index = async({
|
|
|
29
34
|
|
|
30
35
|
log("created index", index_id)
|
|
31
36
|
}
|
|
37
|
+
console.log("ensure_index.ts")
|