Making sure certain fields aren't cleansed.

This commit is contained in:
mike12345567 2021-05-28 12:04:15 +01:00
parent 70019b9b74
commit 6416d7f197
1 changed files with 5 additions and 1 deletions

View File

@ -169,11 +169,15 @@ exports.inputProcessing = (user = {}, table, row) => {
let clonedRow = cloneDeep(row)
// need to copy the table so it can be differenced on way out
const copiedTable = cloneDeep(table)
const dontCleanseKeys = ["type", "_id", "_rev", "tableId"]
for (let [key, value] of Object.entries(clonedRow)) {
const field = table.schema[key]
// cleanse fields that aren't in the schema
if (!field) {
delete clonedRow[key]
if (copiedTable.indexOf(key) === -1) {
delete clonedRow[key]
}
continue
}
clonedRow[key] = exports.coerce(value, field.type)
}