Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit efecd76

Browse files
author
=
committed
Merge remote-tracking branch 'origin/urlgen' into dev
2 parents 0d25d19 + 8647463 commit efecd76

File tree

5 files changed

+9
-191
lines changed

5 files changed

+9
-191
lines changed

.gitattributes

Lines changed: 0 additions & 188 deletions
This file was deleted.

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"mongodb": "^3.6.3",
2828
"morgan": "^1.10.0",
2929
"mysql": "^2.18.1",
30+
"nanoid": "^3.1.18",
3031
"nunjucks": "^3.2.2",
3132
"prom-client": "^12.0.0",
3233
"prometheus-api-metrics": "^3.1.0",

src/db/MongoDB.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { MongoClient, ObjectID } = require("mongodb");
22
var crypto = require('crypto');
3+
const { nanoid } = require('nanoid');
34
const configs = require('../config/config');
45
const utils = require('../utils');
56

@@ -50,7 +51,7 @@ class MongoDB {
5051
try {
5152
let results = (await this.documentsCollection.insertOne(doc));
5253
const documentLink = utils.uuid(results.insertedId.toString());
53-
const linkView = utils.uuid(documentLink);
54+
const linkView = nanoid(5);
5455
this.documentsCollection.updateOne({_id: results.insertedId}, {$set: {documentLink: documentLink, linkView: linkView}});
5556
return documentLink;
5657
} catch (err) {
@@ -117,7 +118,7 @@ class MongoDB {
117118
let index = doc.content.findIndex(line => {
118119
return line.uuid == previousUuid;
119120
});
120-
if (index) {
121+
if (index || index === 0) {
121122
this.documentsCollection.updateOne({documentLink: documentLink}, {
122123
$push: {
123124
content: {

0 commit comments

Comments
 (0)