2016-01-11 12:50:44 -05:00
|
|
|
// Print out subscribers by special country (China, Brazil)
|
|
|
|
|
|
|
|
// Usage:
|
|
|
|
// mongo <address>:<port>/<database> <script file> -u <username> -p <password>
|
|
|
|
|
|
|
|
var countries = ['brazil', 'china'];
|
|
|
|
countries.forEach(function(country) {
|
|
|
|
print('---' + country.toUpperCase() + '---');
|
|
|
|
var cursor = db.users.find({country: country, stripe: {$exists: true}}, {email: 1, country: 1, stripe: 1, name: 1});
|
|
|
|
var users = [];
|
|
|
|
var inactiveUsers = [];
|
|
|
|
while (cursor.hasNext()) {
|
|
|
|
var user = cursor.next();
|
2016-01-11 13:32:23 -05:00
|
|
|
if (!user.stripe.subscriptionID) {
|
2016-01-11 12:50:44 -05:00
|
|
|
inactiveUsers.push(user);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
users.push(user);
|
|
|
|
print([user._id, user.country, user.email, user.name, JSON.stringify(user.stripe, null, 0)].join('\t'));
|
|
|
|
}
|
|
|
|
print('Had', users.length, 'active subscribers and', inactiveUsers.length, 'possible former subscribers in', country, '\n');
|
|
|
|
});
|