Merge branch 'master' of http://github.com/FreeCodeCamp/freecodecamp
This commit is contained in:
23
seed_data/get-emails.js
Normal file
23
seed_data/get-emails.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
require('dotenv').load();
|
||||||
|
var User = require('./../models/User'),
|
||||||
|
secrets = require('../config/secrets'),
|
||||||
|
mongodb = require('mongodb'),
|
||||||
|
MongoClient = mongodb.MongoClient;
|
||||||
|
|
||||||
|
MongoClient.connect(secrets.db, function(err, database) {
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
database.collection('users').aggregate([
|
||||||
|
{$match: { 'email': { $exists: true } } },
|
||||||
|
{$match: { 'email': { $ne: '' } } },
|
||||||
|
{$match: { 'email': { $ne: null } } },
|
||||||
|
{$match: { 'sendMonthlyEmail': true } },
|
||||||
|
{$match: { 'email': { $not: /(test|fake)/i } } },
|
||||||
|
{$group: { '_id': 1, 'emails': {$addToSet: '$email' } } }
|
||||||
|
], function(err, results) {
|
||||||
|
console.log('\"email\"\n\"'+results[0].emails.join('\"\n\"') + '\"');
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
});
|
Reference in New Issue
Block a user