Disclaimer, I’m a newbie on Forest and I need to work on existent code.
Feature(s) impacted
Edition
Observed behavior
I have a JSON field named testField
in schema .forestadmin-schema.json
. But when I edit this field nothing is saved into my DB. It’s normal because I need to perform save on another database.
Expected behavior
So I have created in my forest-express-sequelize collection
a fields entry with get/set functions on this field. But now it doesn’t appear anymore in UI
Failure Logs
Nothing fail.
Field in my .forestadmin-schema.json
{
"field": "testField",
"type": "Json",
"defaultValue": null,
"enums": null,
"integration": null,
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": false,
"isSortable": true,
"isVirtual": false,
"reference": null,
"inverseOf": null,
"validations": []
}
The get/set functions inside my forest-express-sequelize collection
{
field: "testField",
type: "Json",
get: async (obj) => {
try {
const test = await models.test.findOne({ where: { id: obj.id } })
if (test) {
return test.testField;
} else {
return {};
}
} catch (e) {
return null;
}
},
set: async (obj, data) => {
try {
const test = await models.test.findOne({ where: { id: obj.id } })
if (test) {
test.testField = data;
await test.save();
}
return test;
} catch (e) {
return 0;
}
},
}