LKDBHelper-SQLite-ORM icon indicating copy to clipboard operation
LKDBHelper-SQLite-ORM copied to clipboard

请教一下,排序3个问题

Open CCBrother opened this issue 3 years ago • 2 comments
trafficstars

1、模型的字段时间戳是longlong类型,存到数据库却是integer类型,取出的顺序有问题,需要把时间戳转为字符串吗? 2、NSMutableArray *searchResultArray = [TWYIMChatMessageModel searchWithWhere:[NSString stringWithFormat:@"sessionId='%@'", self.sessionModel.sessionId] orderBy:@"sendTimeStamp asc" offset:0 count:20];

@"sendTimeStamp asc" 这里的asc是指数据库的数据升序呢?还是取出来20个数据后,再进行升序? 3、保存数据到数据库的时候可以按字段逆序保存吗?

CCBrother avatar Jun 28 '22 09:06 CCBrother

  1. sqlite 内部其实是无类型的,iOS 5s之后都是64位int了,如果要用 longlong 类型,建议用一个 string 来存,使用时在转为longlong
  2. asc 在数据库内 都是先排序 在取前20个
  3. 数据库是模型存储, 跟字段顺序无关(只有数组那种 才要求有序的吧)

li6185377 avatar Jul 01 '22 01:07 li6185377

明白了,感谢感谢!!!

CCBrother avatar Jul 12 '22 09:07 CCBrother