there is the following block:
export const RAMBlock: Block = {
slug: 'ram-block',
fields: [
{ name: 'type', type: 'text'},
{ name: 'capacity', type: 'number'},
],
};
i want to save capacity as number in database, but on the frontend i would expect graphql payload to return a formatted string {capacity: "16MB" }
i have some thoughts of changing the model to something like "capacity__MB" and so on the frontend to split the key but i guess it's not the best way to go.
any suggestions how to do this?
You could make a third text field, called
formattedRAM
and populate that field with an afterRead hook on the field itself. Then you would use siblingData to populate it.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.