Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MongoClient = require('mongodb').MongoClient;
- var mongoURL = 'mongodb://localhost:27017/';
- module.exports = {
- connect: function(callback) {
- var self = this;
- if (self.db) {
- return process.nextTick(callback.bind(null, null, self.db));
- }
- MongoClient.connect(mongoURL, function(err, db) {
- self.db = db;
- return callback(err, db);
- });
- },
- getDb: function() {
- if (!this.db) {
- throw new Error('not initialized.');
- }
- return this.db;
- }
- };
- var mongoClient = require("./includes/mongo-client");
- var checkVerification = function(username, verificationCode, callback) {
- var cursor = mongoClient.getDb().collection('users').find();
- var result = false;
- cursor.each(function(err, doc) {
- if (doc && doc.verificationDate && (new Date().getTime() - doc.sessionDate) < 1000 * 60 * 15) {
- result = true;
- }
- if (doc == null) {
- callback(result);
- }
- });
- }
- mongoClient.connect(function(err, db){
- console.log('what');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement