I currently have some documents of items for dynamic forms.
Below are 3 samples.
The dataValues property stores the array of dynamic fields and its value.
When I want to list all the documents, how can I do sorting based on the dynamic fields?
For example, from UI side we can sort by First Name, or Middle Name dynamically but the sorting is applied on the related value’s field.
(API pass in ‘First Name’, but actual sorting is on dataValues.value of the same dataValues.label = ‘First Name’).
{
_id: ObjectId("640add3aa23672f23560460d"),
name: 'Irene',
slug: 'irene',
dataValues: [
{
label: 'First Name',
value: 'Irene',
sysName: 'content'
}
]
},
{
_id: ObjectId("640add31a23672f23560460b"),
name: 'Zola',
slug: 'zola',
dataValues: [
{
label: 'First Name',
value: 'Zola',
sysName: 'content'
},
{
label: 'Middle Name',
value: 'Li',
sysName: 'content'
}
]
},
{
_id: ObjectId("640add37a23672f23560460c"),
name: 'Henry',
slug: 'henry',
dataValues: [
{
label: 'First Name',
value: 'Henry',
sysName: 'content'
},
{
label: 'Rich',
value: 'Rich',
sysName: 'content'
}
]
}