nodebb-plugin-dbsearch 6.2.12 → 6.2.14
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/package.json
CHANGED
|
@@ -14,21 +14,23 @@ module.exports = {
|
|
|
14
14
|
// redis is not affected, since everything is string already
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
const batch = require.main.require('./src/batch');
|
|
18
18
|
async function convertIdToString(collection, docs) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
await batch.processArray(docs, async (docs) => {
|
|
20
|
+
await db.client.collection(collection).deleteMany({
|
|
21
|
+
_id: { $in: docs.map(doc => doc._id) },
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const bulk = db.client.collection(collection).initializeUnorderedBulkOp();
|
|
25
|
+
docs.forEach(doc => bulk.insertOne({
|
|
26
|
+
...doc,
|
|
27
|
+
_id: doc._id.toString(),
|
|
28
|
+
}));
|
|
29
|
+
await bulk.execute();
|
|
30
|
+
}, {
|
|
31
|
+
batch: 500,
|
|
32
|
+
});
|
|
33
|
+
progress.incr(docs.length);
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
if (mainDB === 'mongo') {
|
|
@@ -37,7 +37,7 @@ module.exports = {
|
|
|
37
37
|
await db.client.collection('searchtopic').createIndex({ ts: 1 }, { });
|
|
38
38
|
await db.client.collection('searchpost').createIndex({ ts: 1 }, { });
|
|
39
39
|
|
|
40
|
-
const projection = { _id: 1
|
|
40
|
+
const projection = { _id: 1 };
|
|
41
41
|
const topics = await db.client.collection('searchtopic').find({}, { projection }).toArray();
|
|
42
42
|
const posts = await db.client.collection('searchpost').find({}, { projection }).toArray();
|
|
43
43
|
|