Android – order in dbflow

I am trying to implement dbflow in my android project. I have been able to create a table and add rows and columns to it. I have two columns, ID and name. Now, I want to retrieve names from the table and arrange them in descending order of ID. I found this example syntax on the GitHub dbflow page

sqlite.select()
  .from(table)
  .where()
  .orderBy(Customer_Table.customer_id, true)
  .queryList();

sqlite.select()
    .from(table)
    .where()
    .orderBy(Customer_Table.customer_id, true)
    .orderBy(Customer_Table.name, false)
    .queryList();

But I can't understand the meaning of "customer_table. Customer_id" in the code. When I try to put the method orderby(), Android studio recommends using (namealias, namealias, Boolean) as a parameter. How to add namealias to the table? Can someone help me?

resolvent:

When implementing dbflow in a project, it will automatically build a table class for each table model you annotate with @ table annotation

That is, if you have a table named customer, the corresponding class will be customer_ Table. If your table is user, the corresponding class will be user_ Table.

Use this as your customer table:

@Table
public class Customer extends BaseModel {
    @Column
    String customer_name;
}

If you want to use the customer name to order results in the customer table, you can use it this way,

sqlite.select()
  .from(table)
  .where()
  .orderBy(Customer_Table.customer_name, true)
  .queryList();

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>