1

I have the following document sturcture stored in a document table

 {
  firstname: '',
  surname: '',
  ...

  manager: {
    firstname: '',
    surname: ''
    ...
  }
 }

When selecting records with Massive.js i can limit the fields returned by providing an options object.

await dbConn.table.findDoc(criteriaObj, { fields: ['firstname', 'surname'] });

This works great for root fields, but for nested objects; consider the manager field above, Massive returns that field as a JSON string rather than a parsed object.

await dbConn.table.findDoc(criteriaObj, { fields: ['firstname', 'manager'] });

Which returns the following.

[{
  firstname: 'bob',
  manager: '{"firstname":"","surname":""}'
}]

I've trawled through Massive's documentation and not been able to find any reference to using this feature with nested fields.

Is this even possible? Ideally I'd like to craft an options object where i can request any number of fields from the root document but also select any subset of fields from nested objects within that document.

Any information would be greatly appreciated thanks.

ste2425
  • 4,656
  • 2
  • 22
  • 37

0 Answers0