#Datastore.query with predicate doesn't return a list

2 messages · Page 1 of 1 (latest)

wooden plank
#

Hi,
I've just updated to aws-amplify 5.3.11 (from 3.3.8, yes I know!) And my queries to Datastore now only return a single item if I use the predicate.
This used to work, it returned Invoice[]

const invoices = await DataStore.query(Invoice, (i) =>
    i
      .startDate("ge", format(startDate, "yyyy-MM-dd"))
      .endDate("le", format(endDate, "yyyy-MM-dd"))
      .owner("eq", attributes.sub)
  );

Same thing, now returns EagerInvoice

If I do, the below I get EagerInvoice[] which is more like it but I don't want to have to then filter them when the query function provides the predicate option:

const invoices = await DataStore.query(Invoice)

Any ideas what I'm missing?

lilac mural
#

Hey @wooden plank 👋. Whoa! Big upgrade going form v3.X to most recent version. Is it throwing any errors when you query or just the change in behavior? And are you able to share your schema as well just to make sure we're not missing anything?

Definitely recommend taking a look at the updated docs as well to ensure you're up to speed! There's likely been quite a few changes since v3.X:
https://docs.amplify.aws/lib/datastore/data-access/q/platform/js/#query-then-observe-changes