tywalch / electrodb

A DynamoDB library to ease the use of modeling complex hierarchical relationships and implementing a Single Table Design while keeping your query code readable.
MIT License
997 stars 63 forks source link

Filter expressions: Where In operation #356

Open davidusacd opened 7 months ago

davidusacd commented 7 months ago

Hi guys! Congratulations for this amazing library!

It would be possible to incorporate a new operation to make where in operation for filter expressions?

Something like this:

animals.query
  .exhibit({ habitat: "Africa", enclosure: "5b" })
  .where((attr, op) => op.in(attr.name, ['Lion', 'Zebra']))
  .go();

Thank you in advance!

imjma commented 3 months ago

+1 for the IN query

Currently I am using this instead

scan.where(
  ({id}, {name, value}) => `${name(id)} IN (${ids.map((k) => `${value(id, k)}`).join(',')})`
);