Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching a sub array and only outputting the matching data #59

Open
Simranjitk opened this issue Feb 19, 2017 · 0 comments
Open

Searching a sub array and only outputting the matching data #59

Simranjitk opened this issue Feb 19, 2017 · 0 comments

Comments

@Simranjitk
Copy link

I have a collection

marks {
   testers: {
        {
           "class": "math",
           "mark": 81
        },
        {
           "class": "english",
           "mark": 90
        }

    }
}

So, my server method is

SearchSource.defineSource('packages', function(searchText, options) {
    console.dir(searchText);
    if(searchText) {
      var regExp = buildRegExp(searchText);
      var options = {limit: 20};
        var selector = {"testers.class": regExp}

        return marks.find(selector, options).fetch();
      }

    } else {
        return marks.find({}, options).fetch();
    }
  });

This returns every single 'class' object if one of them matches the search query. If I search "english", I want it to just return the word 'english'. How can I do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant