commit 406c23244c8058c4b7cb0d19f5a7e5ee1e2063b1 Author: BRAVO68WEB Date: Mon Jul 26 09:55:13 2021 +0530 Example DB diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e50311b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/* +node_modules/ +package-lock.json \ No newline at end of file diff --git a/app.js b/app.js new file mode 100644 index 0000000..7070fa7 --- /dev/null +++ b/app.js @@ -0,0 +1,33 @@ +const BaseDB = require('dbd.db') +const DB = BaseDB('database') +const Collection = DB.collection({ + name: "Collection", + ttl: 5 //optional +}) +const express = require('express') +const app = express() +const port = 3000 + +app.get('/add/:opinion', (req, res) => { + var id = new Date().getTime(); + var timestamp = new Date().toISOString(); + var opinion = req.params.opinion + console.log(opinion, timestamp) + // console.log(req.params.opinion); + ;(async () => { + await Collection.set({ + id: id, + timestamp: timestamp, + opinion: opinion + }) + + console.log(await Collection.find({ + opinion: "Hi" + })) + })() + res.send('Hello World!') + }) + +app.listen(port, () => { + console.log(`API listening at http://localhost:${port}`) + }) \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..fbdb98d --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "jsondb", + "version": "0.0.0", + "private": true, + "scripts": { + "start": "node app.js" + }, + "dependencies": { + "cookie-parser": "~1.4.4", + "dbd.db": "^1.4.5", + "debug": "~2.6.9", + "express": "~4.16.1", + "lowdb": "^2.1.0", + "morgan": "~1.9.1" + } +}