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

Commit

Permalink
Merge pull request #29 from CodeWe-projet/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Brieuc Dubois committed Nov 26, 2020
2 parents 9a30345 + efecd76 commit 9ffac65
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 191 deletions.
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

0 comments on commit 9ffac65

Please sign in to comment.