nodebb-plugin-dbsearch 6.2.6 → 6.2.8

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/lib/postgres.js CHANGED
@@ -130,7 +130,7 @@ exports.chat.index = async (data, ids) => {
130
130
  try {
131
131
  await db.pool.query({
132
132
  name: `dbsearch-searchIndex-chat`,
133
- text: `INSERT INTO "searchchat" SELECT d."id", d."data"->>'content' "content", (d."data"->>'uid')::text "uid", (d."data"->>'roomId')::bigint "rid" FROM UNNEST($1::text[], $2::jsonb[]) d("id", "data") ON CONFLICT ("id") DO UPDATE SET "content" = COALESCE(EXCLUDED."content", "searchchat"."content"), "uid" = COALESCE(EXCLUDED."uid", "searchchat"."uid"), "rid" = COALESCE(EXCLUDED."rid", "searchchat"."rid")`,
133
+ text: `INSERT INTO "searchchat" SELECT d."id", d."data"->>'content' "content", (d."data"->>'rid')::bigint "rid", (d."data"->>'uid')::text "uid" FROM UNNEST($1::text[], $2::jsonb[]) d("id", "data") ON CONFLICT ("id") DO UPDATE SET "content" = COALESCE(EXCLUDED."content", "searchchat"."content"), "uid" = COALESCE(EXCLUDED."uid", "searchchat"."uid"), "rid" = COALESCE(EXCLUDED."rid", "searchchat"."rid")`,
134
134
  values: [ids, data],
135
135
  });
136
136
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-dbsearch",
3
- "version": "6.2.6",
3
+ "version": "6.2.8",
4
4
  "description": "A Plugin that lets users search posts and topics",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -20,13 +20,12 @@ module.exports = {
20
20
  if (doc._id) {
21
21
  const stringId = doc._id.toString();
22
22
  // eslint-disable-next-line no-await-in-loop
23
+ await db.client.collection(collection).deleteOne({ _id: doc._id });
24
+ // eslint-disable-next-line no-await-in-loop
23
25
  await db.client.collection(collection).insertOne({
24
26
  ...doc,
25
27
  _id: stringId,
26
28
  });
27
-
28
- // eslint-disable-next-line no-await-in-loop
29
- await db.client.collection(collection).deleteOne({ _id: doc._id });
30
29
  }
31
30
  progress.incr(1);
32
31
  }
@@ -47,14 +46,18 @@ module.exports = {
47
46
  }
48
47
 
49
48
  if (mainDB === 'postgres') {
50
- await db.client.query('ALTER TABLE searchtopic ALTER COLUMN id TYPE text USING id::bigint');
51
- await db.client.query('ALTER TABLE searchtopic ALTER COLUMN uid TYPE text USING uid::bigint');
49
+ try {
50
+ await db.client.query('ALTER TABLE searchtopic ALTER COLUMN id TYPE text USING id::bigint');
51
+ await db.client.query('ALTER TABLE searchtopic ALTER COLUMN uid TYPE text USING uid::bigint');
52
52
 
53
- await db.client.query('ALTER TABLE searchpost ALTER COLUMN id TYPE text USING id::bigint');
54
- await db.client.query('ALTER TABLE searchpost ALTER COLUMN uid TYPE text USING uid::bigint');
53
+ await db.client.query('ALTER TABLE searchpost ALTER COLUMN id TYPE text USING id::bigint');
54
+ await db.client.query('ALTER TABLE searchpost ALTER COLUMN uid TYPE text USING uid::bigint');
55
55
 
56
- await db.client.query('ALTER TABLE searchchat ALTER COLUMN id TYPE text USING id::bigint');
57
- await db.client.query('ALTER TABLE searchchat ALTER COLUMN uid TYPE text USING uid::bigint');
56
+ await db.client.query('ALTER TABLE searchchat ALTER COLUMN id TYPE text USING id::bigint');
57
+ await db.client.query('ALTER TABLE searchchat ALTER COLUMN uid TYPE text USING uid::bigint');
58
+ } catch (err) {
59
+ console.error(err.stack);
60
+ }
58
61
  }
59
62
  },
60
63
  };