Skip to content

collection.fastSearch.columns display deep objects #32

@garciadiazjaime

Description

@garciadiazjaime

Hey guys,

I have a model with nested objects, ie.

collection = {
key1: 'string',
key2: {
  name: 'name'
}
}

I would like to display collection.key2.name on the search view
http://mongorilla.herokuapp.com/search/instrument
screen shot 2018-02-26 at 7 05 39 pm

however I noticed this line gets rid of nested objects
https://github.com/gerardobort/mongorilla/blob/master/routes/api/generic.js#L218

I did a fix replacing that line by:

data[i] = collection.fastSearch.columns.reduce((item, key) => {
                                        item[key] = eval(`result.${key}`)
                                        return item
                                    }, {})

Just wanted to check if there were a better way to do this, I just found out this package, seams really cool, but I'm not yet really familiar with.

Thanks,
Cheers.

PD. Nice repo!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions