cvara / rxdb-hooks

React hooks for integrating with RxDB
MIT License
136 stars 6 forks source link

useRxData collection filtering briefly malfunctions #85

Open nukeop opened 5 months ago

nukeop commented 5 months ago

I'm trying to load data belonging to some user like this:

useRxData<Stuff>(
        'stuff',
        (collection) => collection.find().where('user_id').equals(user?.id),
);

This works, but there's a brief moment where it loads everything regardless of user_id. I can't fix it by using row level security, because those other rows are intended to be public, just displayed elsewhere. They flash for a moment, then disappear again. If I console.log the retrieved dcouments, you can see the hook first returns 0 (before fetching), then 11 (with isFetching set to false), then 11 with isFetching set to true, then 2, then 11, then 2 again. 2 is the number of elements after filtering.

image