mirror of
https://github.com/caoer/CodableFirebase.git
synced 2026-04-11 17:44:05 +08:00
Update README.md
This commit is contained in:
15
README.md
15
README.md
@@ -1,5 +1,5 @@
|
||||
# CodableFirebase
|
||||
Use Codable with Firebase
|
||||
Use [Codable](https://developer.apple.com/documentation/swift/codable) with [Firebase](https://firebase.google.com)
|
||||
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](https://travis-ci.org/alickbass/CodableFirebase)
|
||||
@@ -37,3 +37,16 @@ Firestore.firestore().collection("data").document("one").setData(docData) { err
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
And this is how you would decode the same model with [Firebase Firestore](https://firebase.google.com/products/firestore/):
|
||||
|
||||
```swift
|
||||
Firestore.firestore().collection("data").document("one").getDocument { (document, error) in
|
||||
if let document = document {
|
||||
let model = try! FirestoreDecoder().decode(Model.self, from: document.data())
|
||||
print("Model: \(model)")
|
||||
} else {
|
||||
print("Document does not exist")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user