Skip to content

Instantly share code, notes, and snippets.

@bijukunjummen
Created February 1, 2022 04:14
Show Gist options
  • Select an option

  • Save bijukunjummen/66705bc3460983fa737ed9711af95e0e to your computer and use it in GitHub Desktop.

Select an option

Save bijukunjummen/66705bc3460983fa737ed9711af95e0e to your computer and use it in GitHub Desktop.
public ChatRoom getById(String id) {
ApiFuture<DocumentSnapshot> chatRoomSnapshotFuture =
firestore.collection(ServiceConstants.CHAT_ROOMS).document(id).get();
try {
DocumentSnapshot chatRoomSnapshot = chatRoomSnapshotFuture.get();
return new ChatRoom(chatRoomSnapshot.getId(), chatRoomSnapshot.getString("name"));
} catch (Exception e) {
throw new RuntimeException("Could not retrieve by id", e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment