简体   繁体   中英

Getting 1st index from SugarORM

on website SugarORM we can read

Note: Record indexes start at index 1.

and

Load Entity:
Book book = Book.findById(Book.class, 1);

But this 1 in Load Entity is a ID not index. If i have 5 books in DB, and I Delete all, then add next 1 book, this new 1 book will be have ID 6, and index 1, so:

how to delete by index not from ID column ?

A not-very-good approach (as I don't believe there's a built-in way) would be to just do listAll() to get a standard Java list, then access the desired element using .get() .

Obviously this isn't a great way to do it, and would absolutely run into issues on large data sets, but for small tables it will work. Inefficiently.

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