DbFlow的使用笔记

DBFlow的github地址
DbFlow的基本使用我就不介绍了,我只记录开发中遇到的一些复杂一点的用法

DBFlow 查询

复杂组合的条件查询:

        OperatorGroup op = OperatorGroup.clause
                (
                        RegisterUserModel_Table.mobile.eq(mobile)//这是一个条件
                )
                .and(
                        //这是一个条件
                        OperatorGroup.clause()
                                .or(RegisterUserModel_Table.identity.eq(RegisterUserModel.USER_IDENTIFY_BODY))
                                .or(RegisterUserModel_Table.identity.eq(RegisterUserModel.USER_IDENTIFY_GIRL))
                );
        List<RegisterUserModel> list = SQLite.select().from(RegisterUserModel.class)
                .where(op) //执行的时候的查询的条件
                .queryList();

like条件的查询:

    public static List<String> getAppPackageLikeName(String name) {
        OperatorGroup op = OperatorGroup.clause()
                //字段值以name名开头的条件
                .or(AppItem_Table.appName.like(TextUtils.concat(name, "%").toString()))
                //字段值以name名结尾的条件
                .or(AppItem_Table.appName.like(TextUtils.concat("%", name).toString()))
                //字段值以name名处在中间的条件
                .or(AppItem_Table.appName.like(TextUtils.concat("%", name, "%").toString()));
        List<AppItem> list = SQLite.select().from(AppItem.class)
                .where(op).queryList();
        return strList;
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章