in src/scaler/scaler-core/state.js [492:516]
static convertToStorage(stateData) {
/** @type {{[x:string]: any}} */
const doc = {};
const stateDataKeys = Object.keys(stateData);
// Copy values into row that are present and are known keys.
for (const colDef of STATE_KEY_DEFINITIONS) {
if (stateDataKeys.includes(colDef.name)) {
if (colDef.type === 'timestamp') {
// convert millis to Firestore timestamp
doc[colDef.name] = firestore.Timestamp.fromMillis(
stateData[colDef.name],
);
} else {
// copy value
doc[colDef.name] = stateData[colDef.name];
}
}
}
// we never want to update createdOn
delete doc.createdOn;
return doc;
}