I use ajv to validate JSON data model before inserting/updating my database.
Today I want to use this structure:
const dataStructure = {
xxx1234: { mobile: "ios" },
yyy89B: { mobile: "android" }
};
My keys are dynamic because they are ids. Do you know how to validate it with ajv ?
PS: as an alternative solution, i can of course use this structure:
const dataStructure = {
mobiles: [{
id: xxx1234,
mobile: "ios"
}, {
id: yyy89B,
mobile: "android"
}]
};
Then I would have to loop on the array to find the ids I want. All my queries will become more complex, it bothers me.
Thank you for your help !