(existingFields: SchemaFields, putRequest: any)
| 1505 | // to mongoSchemaFromFieldsAndClassName. No validation is done here, it |
| 1506 | // is done in mongoSchemaFromFieldsAndClassName. |
| 1507 | function buildMergedSchemaObject(existingFields: SchemaFields, putRequest: any): SchemaFields { |
| 1508 | const newSchema = {}; |
| 1509 | // @flow-disable-next |
| 1510 | const sysSchemaField = |
| 1511 | Object.keys(defaultColumns).indexOf(existingFields._id) === -1 |
| 1512 | ? [] |
| 1513 | : Object.keys(defaultColumns[existingFields._id]); |
| 1514 | for (const oldField in existingFields) { |
| 1515 | if ( |
| 1516 | oldField !== '_id' && |
| 1517 | oldField !== 'ACL' && |
| 1518 | oldField !== 'updatedAt' && |
| 1519 | oldField !== 'createdAt' && |
| 1520 | oldField !== 'objectId' |
| 1521 | ) { |
| 1522 | if (sysSchemaField.length > 0 && sysSchemaField.indexOf(oldField) !== -1) { |
| 1523 | continue; |
| 1524 | } |
| 1525 | const fieldIsDeleted = putRequest[oldField] && putRequest[oldField].__op === 'Delete'; |
| 1526 | if (!fieldIsDeleted) { |
| 1527 | newSchema[oldField] = existingFields[oldField]; |
| 1528 | } |
| 1529 | } |
| 1530 | } |
| 1531 | for (const newField in putRequest) { |
| 1532 | if (newField !== 'objectId' && putRequest[newField].__op !== 'Delete') { |
| 1533 | if (sysSchemaField.length > 0 && sysSchemaField.indexOf(newField) !== -1) { |
| 1534 | continue; |
| 1535 | } |
| 1536 | newSchema[newField] = putRequest[newField]; |
| 1537 | } |
| 1538 | } |
| 1539 | return newSchema; |
| 1540 | } |
| 1541 | |
| 1542 | // Given a schema promise, construct another schema promise that |
| 1543 | // validates this field once the schema loads. |
no outgoing calls
no test coverage detected
searching dependent graphs…