-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
Info: Estimated number of lines 200 - 250 (with tests)
In the file Schema.ts, we have defined all elements of the schema, such as the supported types (Email, Phone, String, Number, Boolean, etc.).
We should add support for virtual fields. This would involve a field in which a function is defined, and this function would be called each time in a hook.
- The virtual field (the name could be
Virtualin the Schema file) should allow defining a function that would be executed ONLY on read operation of an object using a Wabe hook (there are many examples in thesrc/hooksdirectory). During read operations, it should compute and return the value of the virtual field. In the callback of the function you should have access to the current object.
It is crucial not to store these fields in the database. Therefore, we should add checks in the database controller to ignore virtual fields during save operations.
The proposed structure is:
{
name: 'User',
description: 'User class',
fields: {
email: {
type: 'Email',
required: true,
},
fullName: {
type: 'Virtual',
callback: (user) => `${user.firstName} ${user.lastName}`,
}
},
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels