From 5722979894b53805639407f856cea78a56d725f3 Mon Sep 17 00:00:00 2001 From: aahmed98 <43424656+aahmed98@users.noreply.github.com> Date: Sat, 9 Feb 2019 15:26:57 -0500 Subject: Create database.tsx --- database.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 database.tsx diff --git a/database.tsx b/database.tsx new file mode 100644 index 000000000..9c90326a5 --- /dev/null +++ b/database.tsx @@ -0,0 +1,15 @@ +import { action, configure } from 'mobx'; +import * as mongodb from 'mongodb'; + +export class database { + private MongoClient = mongodb.MongoClient; + private url = 'mongodb://localhost:27017/website'; + + public async update(id: string, field: string, value: string) { + this.MongoClient.connect(this.url, (err, db) => { + let collection = db.collection('documents'); + collection.update({ "id": id }, { $set: { field: value } }); + db.close(); + }); + } +} -- cgit v1.2.3-70-g09d2