Hi, Just wanted to know if I should change my obje...
# community-help
l
Hi, Just wanted to know if I should change my object structure to be better suited for indexing?
Copy code
{
    documentId: 3860,
    exerciseName: "Weighted Plate Bent Over Row",
    exerciseType: "Strength",
    bodyPart: "Back",
    equipment: "Weighted",
    gender: "Male",
    targetMuscle:
      "Infraspinatus, Latissimus Dorsi, Teres Major, Teres Minor , Trapezius Middle Fibers, Trapezius Upper Fibers ",
    synergyst: "Brachialis, Brachioradialis, Deltoid Posterior",
  },
For example separating targetMuscle into array of strings.
j
Yeah you'll be able to facet / filter by each muscle if you have it as an array of strings
Same with synergyst
l
Thanks @Jason Bosco, also just wanted to know, when designing a schema, can some fields be conditional? For example one document might contain
extraCategory: 'kidsExercise'
while the rest of docs wouldn’t have that value.
j
@Lukas Visinskis yes definintely. You can mark fields as
optional: true
in the schema