mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Add createLicenses.js mongodb script
This commit is contained in:
parent
01679982d5
commit
6b78ab3fe8
1 changed files with 31 additions and 0 deletions
31
scripts/mongodb/createLicenses.js
Normal file
31
scripts/mongodb/createLicenses.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
// 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({
|
||||
maxRedeemers: 100,
|
||||
startDate: "2000-01-01T00:00:00.000Z",
|
||||
endDate: "3000-01-01T00:00:00.000Z",
|
||||
type: 'course',
|
||||
creator: userID
|
||||
})
|
||||
};
|
Loading…
Reference in a new issue