30 lines
686 B
JavaScript
30 lines
686 B
JavaScript
import { MongoClient } from 'mongodb';
|
|
/*
|
|
console.log('connecting to ' + process.env.MONGO_CONN_STR);
|
|
const
|
|
*/
|
|
let mongo;
|
|
let db;
|
|
let functionCollection = {};
|
|
|
|
export function init(connectionString) {
|
|
console.log(connectionString);
|
|
mongo = new MongoClient(connectionString);
|
|
mongo.connect().catch(e => {throw e});
|
|
db = mongo.db();
|
|
|
|
return functionCollection;
|
|
}
|
|
|
|
functionCollection.subsribe = function subsribe (b) {
|
|
let collection = db.collection(b);
|
|
collection.find({}, {}).toArray().then(r => console.log);
|
|
}
|
|
|
|
functionCollection.persist = function persist (b) {
|
|
console.log('persist');
|
|
}
|
|
|
|
functionCollection.publish = function publish (b) {
|
|
console.log('publish')
|
|
} |