简体   繁体   中英

How to query with multiple clauses arguments with SugarRecord & Kotlin

I want to filter my query results by 2 clauses but I'm not sure how to do it and I can't find clear explanations on how to do so. Below is what I've tried.

termList = SugarRecord.find(Term::class.java, "type = ? AND category = ?", "hcp, "+ parentCategoryId.toString())

Thanks!

For example:

val termList = SugarRecord.find(Term::class.java,
                "type = ? and category = ?", // where clause
                "hcp", parentCategoryId.toString()) // arguments

Also, you can use Query Builder :

val termList = Select.from(Term::class.java).where(
        Condition.prop("type").eq("hcp"), // type =(equals) ?
        Condition.prop("category").eq(parentCategoryId.toString())).list()

More info here: http://satyan.github.io/sugar/query.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM