gpt4 book ai didi

android - Realm 是否支持Android 上的模糊查询

转载 作者:太空宇宙 更新时间:2023-11-03 12:46:47 25 4
gpt4 key购买 nike

我的团队决定使用 Realm 作为数据库,但我有一个问题要问,Realm 是否支持像 SQLite 这样使用关键字 'like' 或 '%' 的模糊查询。有时我们需要使用模糊查询

最佳答案

LIKE query is supported since 2.3.0.

public RealmQuery<E> like(String fieldName,
String value,
Case casing)

Condition that the value of field matches with the specified substring, with wildcards:
'*' matches [0, n] unicode chars
'?' matches a single unicode char.

Parameters:
fieldName - the field to compare.
value - the wildcard string.
casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

例子:

realm.where(Person.class).like("name", "*").findAll();
realm.where(Person.class).like("name", "?ohn*", Case.SENSITIVE).findAll();

关于android - Realm 是否支持Android 上的模糊查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42109558/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com