Skip to content

Commit

Permalink
Hoist constant array
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-gross committed Apr 8, 2016
1 parent 744c777 commit ebb4ad9
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,21 @@ function transformUpdateOperator(operator, flatten) {
}
}

const specialKeysForUntransform = [
'_id',
'_hashed_password',
'_acl',
'_email_verify_token',
'_perishable_token',
'_tombstone',
'_session_token',
'updatedAt',
'_updated_at',
'createdAt',
'_created_at',
'expiresAt',
'_expiresAt',
];

// Converts from a mongo-format object to a REST-format object.
// Does not strip out anything based on a lack of authentication.
Expand Down Expand Up @@ -645,22 +660,7 @@ function untransformObject(schema, className, mongoObject, isNestedObject = fals

var restObject = untransformACL(mongoObject);
for (var key in mongoObject) {
const specialKeys = [
'_id',
'_hashed_password',
'_acl',
'_email_verify_token',
'_perishable_token',
'_tombstone',
'_session_token',
'updatedAt',
'_updated_at',
'createdAt',
'_created_at',
'expiresAt',
'_expiresAt',
];
if (isNestedObject && _.includes(specialKeys, key)) {
if (isNestedObject && _.includes(specialKeysForUntransform, key)) {
restObject[key] = untransformObject(schema, className, mongoObject[key], true);
continue;
}
Expand Down

0 comments on commit ebb4ad9

Please sign in to comment.