Skip to content

Instantly share code, notes, and snippets.

@ts95
Created June 23, 2017 23:25
Show Gist options
  • Save ts95/697cbfa4dc2903702442e5dad32051a2 to your computer and use it in GitHub Desktop.
Save ts95/697cbfa4dc2903702442e5dad32051a2 to your computer and use it in GitHub Desktop.
Example of fetching a book by its id and printing out the title of it
let db = FIRDatabase.database()
let bookRef = db.reference(withPath: Endpoint.book("-KnEUaDbm6-snUq_Ojzo").path)
bookRef.observeSingleEvent(of: .value, with: { snapshot in
guard let book = Book(snapshot: snapshot) else { return }
print(book.title)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment