From 05b985a67cbce20ed474517fe8525ddc41973313 Mon Sep 17 00:00:00 2001 From: heliocodacy <46491761+heliocodacy@users.noreply.github.com> Date: Tue, 27 Oct 2020 11:07:39 +0000 Subject: [PATCH 1/4] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a4b2ab6..d85cedc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a07897bbee9a4866a9f9d2b26ba9c652)](https://www.codacy.com/manual/Codacy-ACME/nodeproject?utm_source=github.com&utm_medium=referral&utm_content=codacy-acme/nodeproject&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/a07897bbee9a4866a9f9d2b26ba9c652)](https://www.codacy.com/manual/Codacy-ACME/nodeproject?utm_source=github.com&utm_medium=referral&utm_content=codacy-acme/nodeproject&utm_campaign=Badge_Coverage) # nodeproject +### this is an issue ## the description of this project From fdb46e1886f773070af658eb2b71ec769310ef6c Mon Sep 17 00:00:00 2001 From: heliocodacy <46491761+heliocodacy@users.noreply.github.com> Date: Tue, 27 Oct 2020 11:14:11 +0000 Subject: [PATCH 2/4] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d85cedc..0e1705d 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,5 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/a07897bbee9a4866a9f9d2b26ba9c652)](https://www.codacy.com/manual/Codacy-ACME/nodeproject?utm_source=github.com&utm_medium=referral&utm_content=codacy-acme/nodeproject&utm_campaign=Badge_Coverage) # nodeproject ### this is an issue +####### orly?! ## the description of this project From 420a59fd084f6d14c308cef5cfb90be158535926 Mon Sep 17 00:00:00 2001 From: heliocodacy <46491761+heliocodacy@users.noreply.github.com> Date: Tue, 27 Oct 2020 11:17:27 +0000 Subject: [PATCH 3/4] Create memo-dao.js --- src/server/data/memo-dao.js | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/server/data/memo-dao.js diff --git a/src/server/data/memo-dao.js b/src/server/data/memo-dao.js new file mode 100644 index 0000000..1434f7a --- /dev/null +++ b/src/server/data/memo-dao.js @@ -0,0 +1,39 @@ +/* The MemosDAO must be constructed with a connected database object */ +function MemosDAO(db) { + + "use strict"; + + /* If this constructor is called without the "new" operator, "this" points + * to the global object. Log a warning and call it correctly. */ + if (false === (this instanceof MemosDAO)) { + console.log("Warning: MemosDAO constructor called without 'new' operator"); + return new MemosDAO(db); + } + + const memosCol = db.collection("memos"); + + this.insert = (memo, callback) => { + + // Create allocations document + const memos = { + memo, + timestamp: new Date() + }; + + memosCol.insert(memos, (err, result) => !err ? callback(null, result) : callback(err, null)); + }; + + this.getAllMemos = (callback) => { + + memosCol.find({}).sort({ + timestamp: -1 + }).toArray((err, memos) => { + if (err) return callback(err, null); + if (!memos) return callback("ERROR: No memos found", null); + callback(null, memos); + }); + }; + +} + +module.exports = { MemosDAO }; From edd3cfda5662da85e5fc40ecd6528182770fdee8 Mon Sep 17 00:00:00 2001 From: Dan Putman <57899154+dan-codacy@users.noreply.github.com> Date: Tue, 9 Mar 2021 21:29:16 -0500 Subject: [PATCH 4/4] Update README.md Update headers --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e1705d..a91dc8d 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,5 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/a07897bbee9a4866a9f9d2b26ba9c652)](https://www.codacy.com/manual/Codacy-ACME/nodeproject?utm_source=github.com&utm_medium=referral&utm_content=codacy-acme/nodeproject&utm_campaign=Badge_Coverage) # nodeproject ### this is an issue -####### orly?! +######## orly?! ## the description of this project