This commit is contained in:
2026-05-13 19:58:16 +03:00
commit f5adeb292b
78 changed files with 12024 additions and 0 deletions

28
lib/mongo.js Normal file
View File

@@ -0,0 +1,28 @@
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 })
}