nodebb-plugin-dbsearch 5.0.3 → 5.0.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-dbsearch",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "description": "A Plugin that lets users search posts and topics",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -1,49 +1,28 @@
1
1
  'use strict';
2
2
 
3
3
 
4
- const async = require.main.require('async');
5
4
  const winston = require.main.require('winston');
6
5
  const db = module.parent.require('./database');
7
6
 
8
7
  module.exports = {
9
8
  name: 'Changing dbsearch mongodb search schema to use _id',
10
9
  timestamp: Date.UTC(2018, 10, 26),
11
- method: function (callback) {
10
+ method: async function () {
12
11
  const nconf = require.main.require('nconf');
13
12
  const isMongo = nconf.get('database') === 'mongo';
14
13
  if (!isMongo) {
15
- return callback();
14
+ return;
16
15
  }
17
16
 
18
17
  const plugin = require('../lib/dbsearch');
19
- const client = db.client;
20
-
21
- async.series([
22
- function (next) {
23
- client.collection('searchtopic').removeMany({}, next);
24
- },
25
- function (next) {
26
- client.collection('searchpost').removeMany({}, next);
27
- },
28
- function (next) {
29
- client.collection('searchtopic').dropIndex({ id: 1 }, function (err) {
30
- if (err) {
31
- winston.error(err);
32
- }
33
- next();
34
- });
35
- },
36
- function (next) {
37
- client.collection('searchpost').dropIndex({ id: 1 }, function (err) {
38
- if (err) {
39
- winston.error(err);
40
- }
41
- next();
42
- });
43
- },
44
- async function () {
45
- await plugin.reindex();
46
- },
47
- ], callback);
18
+ await db.client.collection('searchtopic').deleteMany({});
19
+ await db.client.collection('searchpost').deleteMany({});
20
+ try {
21
+ await db.client.collection('searchtopic').dropIndex({ id: 1 });
22
+ await db.client.collection('searchpost').dropIndex({ id: 1 });
23
+ } catch (err) {
24
+ winston.error(err.stack);
25
+ }
26
+ await plugin.reindex();
48
27
  },
49
28
  };