objectbox / objectbox/objectbox-java
Request : LiveData observing Query.count instead of Query.find
未关闭
还没有人认领这个 Issue。
enhancement
- 主要语言
- Java
- 星标
- 4.6k
- 派生
- 311
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hi,
I'd like to use LiveData to observe the number of items resulting of a given query (the equivalent of Query.count() or Query.findLazy().size()).
As of v2.4.0, LiveData only calls Query.find, so the only implementation I came up with is not optimal at all
// Get all results as objects
// NB : db.queryContentSearch is a Query<Content>
ObjectBoxLiveData<Content> livedata = new ObjectBoxLiveData<>(db.queryContentSearch(query, metadata, favouritesOnly));
// Instanciated objects are useless because we just actually count them !
MediatorLiveData<Integer> result = new MediatorLiveData<>();
result.addSource(livedata, v -> result.setValue(v.size()));
return result;
=> Would it be possible in future versions to build LiveData's that observe Query.count ?
Or have I overlooked a feature that already exists ?
Thanks a lot for your help,
-Robb
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查当前调用 Query.find 的 LiveData 行为,然后比较 issue 中描述的 Query.count 和 Query.findLazy API。完成的标准是:LiveData 选项可以观察查询的数量,而无需将所有结果对象具体化,并且会在查询结果发生变化时更新。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, java
- 领域
- database, mobile
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100