Hello, we have recently run into an issue, in some of the schemas (ex: Logs) we have optional fields that have relations, and then when you query the document where this field is undefined, Forest shows an error “Your server encountered an error”. It was working fine in the old version, any way to make it work in the new version?
In one of the other cases we have made this workaround, but it is not ideal since the relation is lost:
collection.addField('registrationOrPurchase', {
columnType: 'String',
dependencies: ['registration', 'purchase'],
getValues: records =>
records.map(record => {
if (record.registration) return `registration id: ${record.registration}`;
else if (record.purchase) return `Purchase id: ${record.purchase}`;
return undefined;
}),
});
Expected behavior
Omit the optional field if undefined
Failure Logs
===== An exception was raised =====
GET /Log/64e3283163ez305d6e4055d3?{
timezone: Europe/Stockholm
}
Missing one of expected fields: '_id'
Context
- Project name: PayAtt Internal Admin Portal
- Team name: All teams
- Environment name: DEVELOPMENT | VLADYSLAVNIKIFOROV (REWRITE)
- Agent (forest package) name & version: “@forestadmin/agent”: “^1.16.2”, “@forestadmin/datasource-mongoose”: “^1.5.1”
- Database type: MongoDB
- Recent changes made on your end if any: Migrating to a new agent