chatItemsAround method

Selectable<ChatItemsAroundResult> chatItemsAround(
  1. String chatId,
  2. PreciseDateTime at,
  3. double before,
  4. int after,
)
inherited

Implementation

Selectable<ChatItemsAroundResult> chatItemsAround(
  String chatId,
  PreciseDateTime at,
  double before,
  int after,
) {
  return customSelect(
    'SELECT * FROM (SELECT * FROM chat_item_views INNER JOIN chat_items ON chat_items.id = chat_item_views.chat_item_id WHERE chat_item_views.chat_id = ?1 AND at <= ?2 ORDER BY at DESC LIMIT ?3 + 1) AS a UNION SELECT * FROM (SELECT * FROM chat_item_views INNER JOIN chat_items ON chat_items.id = chat_item_views.chat_item_id WHERE chat_item_views.chat_id = ?1 AND at > ?2 ORDER BY at ASC LIMIT ?4) AS b ORDER BY at ASC',
    variables: [
      Variable<String>(chatId),
      Variable<int>($ChatItemsTable.$converterat.toSql(at)),
      Variable<double>(before),
      Variable<int>(after),
    ],
    readsFrom: {chatItemViews, chatItems},
  ).map(
    (QueryRow row) => ChatItemsAroundResult(
      chatId: row.read<String>('chat_id'),
      chatItemId: row.read<String>('chat_item_id'),
      id: row.read<String>('id'),
      chatId1: row.read<String>('chat_id'),
      authorId: row.read<String>('author_id'),
      at: $ChatItemsTable.$converterat.fromSql(row.read<int>('at')),
      status: $ChatItemsTable.$converterstatus.fromSql(
        row.read<int>('status'),
      ),
      data: row.read<String>('data'),
      cursor: row.readNullable<String>('cursor'),
      ver: row.read<String>('ver'),
    ),
  );
}