blinkdb-js / blinkdb

🗃️ An in-memory JS database optimized for large scale storage on the frontend.
https://blinkdb.io
MIT License
119 stars 10 forks source link

Data not updating when changing query with useMany #24

Closed aesqe closed 1 year ago

aesqe commented 1 year ago

Hello and thank you for this wonderful library! It's super easy to use and very performant.

My question is: is there a way to update the query in the useMany hook?

It seems it will only re-query the data when something is changed in the DB, as it's using watch.

My use case is having a checkbox to toggle the display of deleted items, e.g.:

export const useItems = (includeDeleted = true) => {
  const itemsTable = useTable((model: Model) => model.items)

  const query = includeDeleted ? {} : { where: { deleted: false } }

  const { data, error, state } = useMany(itemsTable, query)

  return data
}

But the data is always the same as the first returned values.

Is this expected? Or am I doing something wrong?

Thank you very much in advance! 🙇

maradotwebp commented 1 year ago

No, this should work, BlinkDB is doing something wrong here :) I'll take a look, this seems like a quick fix.

maradotwebp commented 1 year ago

Now fixed in the latest release

aesqe commented 1 year ago

@froehlichA great, thank you very much! 🙂