Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support simple count() with liveQuery() #436

Open
mihaa1 opened this issue May 12, 2024 · 0 comments
Open

Support simple count() with liveQuery() #436

mihaa1 opened this issue May 12, 2024 · 0 comments

Comments

@mihaa1
Copy link

mihaa1 commented May 12, 2024

Several places in my app depend on the number of entities.
Could be 0, 1 or more than 1.
I would like to get the count only from live query.

Example: Im saving the count of the users the user added under her organization in the global state when loading the app. But this can change any time she will add/delete a user. I would like to app to reflect that without rerunning
await remult.repo(User).count()

A solution like:

useEffect(() => {
  return remult.repo(User)
    .liveQuery({
       count: true
    })
    .subscribe(info => setTasks(info.applyChanges))
}, [])

or
useEffect(() => {
return remult.repo(User)
.liveQuery(
.count()
.subscribe(info => setTasks(info.applyChanges))
}, [])
Both of these will return the item count only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant