Meteor-Community-Packages / Meteor-Community-Packages/meteor-autocomplete

Supporting multiple collections?

Open
#57 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
CoffeeScript
Stars
350
Forks
106
PR merge metrics
No merged PRs in 30d

Description

Hi,
I implemented this autocomplete and I love it, however it seems to only work with one collection - can it work with multiple at the same time?

So if in settings I limit to 10, and the first collection delivers 7 results and 2nd collection delivers 3, I should see all results. But I only see the results of whichever collection is first declared in the settings. Example:

```
if (Meteor.isClient) {

Template.autoComplete.settings = function() {
return {
position: "bottom",
limit: 10,
rules: [
{
token: '',
collection: Customers,
field: "name",
matchAll: true,
template: Template.autocompleteCustomer
},
{
token: '',
collection: Clients,
field: "title",
matchAll: true,
template: Template.autocompleteClient
}
]
}
};

}
```

Problem:
When rules array contains 2 separate collections, and are declared together as shown above, only the first one declared in the array will deliver results. So in the example above only the customers will deliver results.

How can I use both collections at the same time?

Thanks,

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the client-side settings entry point and the rules array shown in the issue, then reproduce the behavior with Customers and Clients using limit 10. Trace how collection results are gathered and rendered; done means results from both collections appear together up to the configured limit.

Written by the indexing model from the issue text.

Assessment

Tech stack
coffeescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.