Meteor-Community-Packages / Meteor-Community-Packages/meteor-autocomplete
Question - do I have to denormalize due to MongoDB distinct() feature missing?
- Dominant language
- CoffeeScript
- Stars
- 350
- Forks
- 106
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I have a collection Songs which contains data in the following format:
`{artist:"Dream Theater", title: "Pull me under"}, {artist:"Dream Theater", title: "Finally free"}`
There are more than 5000 entries, so I definetely need server-side autocompletion.
On server I published the collection:
```
Meteor.publish("autocompleteArtists", function(selector, options) {
Autocomplete.publishCursor(Songs.find(selector, options), this);
this.ready();
});
```
Client subscription looks like:
```
Template.home.helpers({
settings: function() {
return {
position: "top",
limit: 5,
rules: [{
collection: 'Songs',
subscription: 'autocompleteArtists',
field: "artist",
template: Template.songItem
}]
};
}
});
```
Should I have both collection and subscription in the settings() function?
Last part, the client template:
`{{> inputAutocomplete settings=settings id="artistInput" type="text" placeholder="Artist" length="20"}}`
My purpose is to look for an artist and when I select it, to subscribe to a simple server publish which returns all songs belonging to that artist. The thing is, if I have multiple entries with the same artist, of course, the list of results is showing the artist multiple times. I would need to to somehow a "distinct" publish which would return all artists, but there's no such a feature in Meteor. I found some things implementing the aggregation and distinct, but I don't see how to use Autocomplete publishCursor function... My temporary solution was to denormalize and add a Artists collection, but I should not do that.
Is there a simpler way?
Contributor guide
Research direction
Start by tracing the `Meteor.publish("autocompleteArtists")` entry point, `Autocomplete.publishCursor`, and the client `settings()` configuration. Determine whether the package supports distinct artist results while preserving selection and song subscriptions; done means duplicate artists are eliminated and selecting an artist still retrieves its songs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100