2016-07-21 14:23:05 -04:00
|
|
|
// Create 100 long-lasting licenses for a given user
|
|
|
|
|
|
|
|
// Usage
|
|
|
|
// ---------------
|
|
|
|
// In mongo shell
|
|
|
|
//
|
|
|
|
// > createLicenses('<user id string>');
|
|
|
|
|
|
|
|
var createLicenses = function updatePrepaid(userStringID) {
|
|
|
|
try {
|
|
|
|
var userID = ObjectId(userStringID);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
print('Invalid ObjectId string given:', userStringID, e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var user = db.users.findOne({_id: userID});
|
|
|
|
if (!user) {
|
|
|
|
print('User not found');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
db.prepaids.save({
|
2016-07-21 19:41:39 -04:00
|
|
|
redeemers: [],
|
2016-07-21 14:23:05 -04:00
|
|
|
maxRedeemers: 100,
|
|
|
|
startDate: "2000-01-01T00:00:00.000Z",
|
|
|
|
endDate: "3000-01-01T00:00:00.000Z",
|
|
|
|
type: 'course',
|
|
|
|
creator: userID
|
|
|
|
})
|
|
|
|
};
|