Files
loop-etl-rocketchat/lib/mongo.js
2026-05-13 20:03:28 +03:00

29 lines
544 B
JavaScript

const mongo = require('mongodb')
//
// Declare internals
//
let client = {}
//
// Connect to the db and create a connection
// pool
//
module.exports.connect = function (config) {
client = new mongo.MongoClient(config.source.uri)
return client.connect()
}
module.exports.close = function () {
return client.close()
}
module.exports.collection = function (collection) {
return client.db().collection(collection)
}
module.exports.gridFsBucket = function (bucketName) {
return new mongo.GridFSBucket(client.db(), { bucketName })
}