diff --git a/mongo.js b/mongo.js index 204aa97..4eaa64e 100644 --- a/mongo.js +++ b/mongo.js @@ -22,6 +22,22 @@ class Mongo { client.close(); }) } + + insert(collectionName, entity, callback) { + this.db.collection(collectionName).insert(entity, (error, result) => { + assert.equal(null, error, `Unable to insert ${collectionName} entity: ${error}.`); + console.log(`Entity ${collectionName} inserted.`); + callback(result); + }) + } + + update(collectionName, entity, query, callback) { + this.db.collection(collectionName).update(query, entity, (error, result) => { + assert.equal(null, error, `Unable to update ${collectionName} entity: ${error}.`); + console.log(`Entity ${collectionName} updated.`); + callback(result); + }) + } } module.exports = Mongo; \ No newline at end of file