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();
If a facet is configured to use shards, the default behavior should be to query every shard if none is specified.
Some positive outcomes:
Before
After