mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 22:13:32 -04:00
Fix updatePrepaid.js user updates
This commit is contained in:
parent
1e0aa1a375
commit
c3381c1274
1 changed files with 8 additions and 4 deletions
|
@ -54,13 +54,17 @@ var updatePrepaid = function updatePrepaid(stringID, originalUpdate) {
|
|||
print('\nUpdate prepaid',
|
||||
JSON.stringify(prepaidUpdate, null, ' '),
|
||||
db.prepaids.update(
|
||||
{_id: id},
|
||||
{ _id: id },
|
||||
{ $set: prepaidUpdate }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
var userUpdate = _.pick(originalUpdate, 'startDate', 'endDate' );
|
||||
var userUpdate = _(originalUpdate)
|
||||
.pick('startDate', 'endDate' )
|
||||
.transform(function(result, value, key) { result['coursePrepaid.'+key] = value })
|
||||
.value();
|
||||
|
||||
if (_.isEmpty(userUpdate)) {
|
||||
print('\nSkipping user update, nothing to update.')
|
||||
}
|
||||
|
@ -69,8 +73,8 @@ var updatePrepaid = function updatePrepaid(stringID, originalUpdate) {
|
|||
JSON.stringify(userUpdate, null, ' '),
|
||||
db.users.update(
|
||||
{'coursePrepaid._id': id},
|
||||
{$set: userUpdate},
|
||||
{multi: true}
|
||||
{ $set: userUpdate },
|
||||
{ multi: true }
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue