-
Notifications
You must be signed in to change notification settings - Fork 0
Searching
Max edited this page May 22, 2015
·
2 revisions
With the help of the very excellent meteor-easy-search package, searching with Meteor is pretty simple.
- Install meteor easy search
meteor add matteodem:easy-search
- On the client and server:
//Replace Cats with your collection name
Cats = new Mongo.Collection('cats');
//Argument is array of fields to search for
Cats.initEasySearch(['furColor', 'name']);
- Add this template to your HTML and display it somewhere
<template name="searchBox">
<!--replace index="cats" with the name of your collection-->
{{> esInput index="cats" placeholder="Search..." }}
<ul>
{{#esEach index="cats"}}
<!--replace cat with the name of your template-->
{{> cat}}
<br/>
{{/esEach}}
</ul>
</template>
That's it! Your application now supports Mongo text searching. Here is an example application using this method.
See the easy search docs for more information.