| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- const fs = require('fs')
- const mongojs = require('../../app/js/infrastructure/mongojs')
- const { db, ObjectId } = mongojs
- const async = require('async')
- console.log('Finding users for ids specified')
- const text = fs.readFileSync(__dirname + '/beta-users.txt')
- const textByLine = text
- .toString()
- .split('\n')
- .map(function(stringId) {
- return ObjectId(stringId)
- })
- db.users.find({ _id: { $in: textByLine } }, function(err, users) {
- if (err) throw err
- if (users.length) {
- console.log('Found ' + users.length + ' users')
- async.each(
- users,
- function(user, callback) {
- console.log('setting betaProgram==true for: ' + user._id)
- db.users.update(
- {
- _id: user._id
- },
- {
- $set: {
- betaProgram: true
- }
- },
- callback
- )
- },
- function(result, err) {
- if (err) {
- console.log(err)
- }
- process.exit(0)
- }
- )
- } else {
- console.log('No users found matching those ids')
- process.exit(0)
- }
- })
|