UNPKG

happn-service-mongo-2

Version:

service plugin for running happn on a mongo database, for happn-3 instances

20 lines (16 loc) 558 B
var MongoClient = require('mongodb').MongoClient; module.exports = function(url, collectionName, callback) { MongoClient.connect(url, { useNewUrlParser: true, useUnifiedTopology: true }, function( err, client ) { if (err) return callback(err); let db = client.db(collectionName); let collection = db.collection(collectionName); collection.drop(function(err) { if (err && err.message != 'ns not found') if (err) console.log('error clearing mongodb: ' + err.message); client.close(callback); }); }); };