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',
|
print('\nUpdate prepaid',
|
||||||
JSON.stringify(prepaidUpdate, null, ' '),
|
JSON.stringify(prepaidUpdate, null, ' '),
|
||||||
db.prepaids.update(
|
db.prepaids.update(
|
||||||
{_id: id},
|
{ _id: id },
|
||||||
{ $set: prepaidUpdate }
|
{ $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)) {
|
if (_.isEmpty(userUpdate)) {
|
||||||
print('\nSkipping user update, nothing to update.')
|
print('\nSkipping user update, nothing to update.')
|
||||||
}
|
}
|
||||||
|
@ -69,8 +73,8 @@ var updatePrepaid = function updatePrepaid(stringID, originalUpdate) {
|
||||||
JSON.stringify(userUpdate, null, ' '),
|
JSON.stringify(userUpdate, null, ' '),
|
||||||
db.users.update(
|
db.users.update(
|
||||||
{'coursePrepaid._id': id},
|
{'coursePrepaid._id': id},
|
||||||
{$set: userUpdate},
|
{ $set: userUpdate },
|
||||||
{multi: true}
|
{ multi: true }
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue