Skip to content

Add ability to pass collection to query method #6

@andymerskin

Description

@andymerskin

Having a Spotr instance be tied to a single collection through initial configuration, or being assigned later is an inconvenient limitation when someone wants to search similar collections using the same fields and keyword matchers. Cloning a Spotr instance or writing a duplicate configuration isn't DRY.

Use case:

  • I want to search multiple collections, derived from one or more collections. For instance, I have a master collection of pages within an application, each with their own metadata. The application gives the user recently visited places or favorite places, which may be managed in separate arrays.

Example:

search.query(collection, query)
// => [filtered collection]

Error handling:

  • Need to handle errors where a field doesn't exist when it's defined in fields or filters
  • Need to handle empty collections

Other considerations:

  • This will be API breaking, but we're in alpha, no biggy
  • Remove class-level collection property. Collections must always be passed into query()
  • Could memoize the query() method:
const queryRecents = query => {
  return search.query(recentsCollection, query)
}

queryRecents('balances')

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions