Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

node.js 584B

12345678910111213141516171819202122232425262728
  1. var assert = require('assert');
  2. var mongo = require('mongodb');
  3. var uri = process.env.MQUERY_URI || 'mongodb://localhost/mquery';
  4. var client;
  5. var db;
  6. exports.getCollection = function(cb) {
  7. mongo.MongoClient.connect(uri, function(err, _client) {
  8. assert.ifError(err);
  9. client = _client;
  10. db = client.db();
  11. var collection = db.collection('stuff');
  12. // clean test db before starting
  13. db.dropDatabase(function() {
  14. cb(null, collection);
  15. });
  16. });
  17. };
  18. exports.dropCollection = function(cb) {
  19. db.dropDatabase(function() {
  20. client.close(cb);
  21. });
  22. };