Memoize list entries and wrap model data

This commit is contained in:
Misode
2021-09-24 03:47:15 +02:00
parent b12e81fff0
commit 6e4850d5a9
7 changed files with 31 additions and 28 deletions

View File

@@ -75,13 +75,14 @@ export async function getModel(version: VersionId, id: string): Promise<DataMode
}
try {
const schema = versionData.schemas.get(schemaName)
const model = new DataModel(schema)
const model = new DataModel(schema, { wrapLists: true, verbose: true })
if (Models[id]) {
model.reset(Models[id].model.data, false)
} else {
model.validate(true)
model.history = [JSON.stringify(model.data)]
}
console.log(model.data)
Models[id] = { model, version }
} catch (e) {
throw new Error(`Cannot get generator "${id}" for version "${version}": ${message(e)}`)