Skip to content

Default behavior when querying over a sharded index #17

@s-fletcher

Description

@s-fletcher

If a facet is configured to use shards, the default behavior should be to query every shard if none is specified.

Some positive outcomes:

  • Minimizes code when querying all shards (as shown below)
  • Removes anti-pattern to define a shard count in some configuration file to reference outside of facet
  • Allows previous pattern to prevent breaking changes

Before

const promises = [];
for(let i = 0; i < SHARD_COUNT; i++) {
    promises.push(Facet.query({ partition }, i).list());
}
const results = await Promise.all(promises);
const records = results.map((result) => result.records).flat();

After

const { records } = await Facet.query({ partition }).list();

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions