Closed Segfaultd closed 2 years ago
Hi segfaultd
Sadly that would not work with just a handler.
You would need to provide at least:
filter(createdAt > undoTransformation(valueProvidedInFrontend)) !== filter(doTransformation(valueInDb) > valueProvidedInFrontend)
If you need neither of those features, you can do the following:
collection
.addField('created_at_new', {
columnType: 'Number',
dependencies: ['created_at'],
getValues: records => records.map(r => (field as Date).getDay())
})
.removeField('created_at')
.renameField('created_at_new', 'created_at')
We'll be releasing a plugin system shortly so that customers can write plugins as they need and use the following syntax:
import { reformatField } from './my-plugins';
collection
.use(reformatField, { name: 'created_at', handler: value => value.getDay() })
Also, I see that you have a cast in your code.
Did you setup the typing generation? You really should! It helps a ton when building an agent
Hi @romain-gilliotte and thanks for the feedback!
My issue is that in case of CSV export, some of my fields return a full timestamp like "2022-06-07T13:21:06.150Z" when I would actually appreciate to only extract "DD/MM/YYYY" thus why I need to reformat the field "otf" :D
As of today, our CSV exporter is not customizable in any way (it's a feature from the early days of the company).
You can generate files from smart actions to customize the output as you want
If generating a big CSV, providing a stream to the resultBuilder
is supported
collection.addAction('Export Data', {
scope: 'Global',
generateFile: true,
execute: async (context, resultBuilder) => {
return resultBuilder.file('StringThatWillBeInTheFile', 'filename.csv', 'application/csv');
},
});
You can then remove the default export from the frontend using Roles
https://docs.forestadmin.com/user-guide/project-settings/teams-and-users/manage-roles
Make sense! Thank you @romain-gilliotte
Expected behavior
Would be nice to be able to reformat a field "on-the-fly". Something like this
Actual behavior
This would return a field on a newer format