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

Dev #29

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 0 additions & 188 deletions .gitattributes

This file was deleted.

5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"mongodb": "^3.6.3",
"morgan": "^1.10.0",
"mysql": "^2.18.1",
"nanoid": "^3.1.18",
"nunjucks": "^3.2.2",
"prom-client": "^12.0.0",
"prometheus-api-metrics": "^3.1.0",
Expand Down
5 changes: 3 additions & 2 deletions src/db/MongoDB.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { MongoClient, ObjectID } = require("mongodb");
var crypto = require('crypto');
const { nanoid } = require('nanoid');
const configs = require('../config/config');
const utils = require('../utils');

Expand Down Expand Up @@ -50,7 +51,7 @@ class MongoDB {
try {
let results = (await this.documentsCollection.insertOne(doc));
const documentLink = utils.uuid(results.insertedId.toString());
const linkView = utils.uuid(documentLink);
const linkView = nanoid(5);
this.documentsCollection.updateOne({_id: results.insertedId}, {$set: {documentLink: documentLink, linkView: linkView}});
return documentLink;
} catch (err) {
Expand Down Expand Up @@ -117,7 +118,7 @@ class MongoDB {
let index = doc.content.findIndex(line => {
return line.uuid == previousUuid;
});
if (index) {
if (index || index === 0) {
this.documentsCollection.updateOne({documentLink: documentLink}, {
$push: {
content: {
Expand Down
Loading