Skip to content

Commit 0d13034

Browse files
author
Oleksii Dykan
authored
Update README.md
1 parent b8c4586 commit 0d13034

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# CodableFirebase
2-
Use Codable with Firebase
2+
Use [Codable](https://developer.apple.com/documentation/swift/codable) with [Firebase](https://firebase.google.com)
33

44
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
55
[![Build Status](https://travis-ci.org/alickbass/CodableFirebase.svg?branch=master)](https://travis-ci.org/alickbass/CodableFirebase)
@@ -37,3 +37,16 @@ Firestore.firestore().collection("data").document("one").setData(docData) { err
3737
}
3838
}
3939
```
40+
41+
And this is how you would decode the same model with [Firebase Firestore](https://firebase.google.com/products/firestore/):
42+
43+
```swift
44+
Firestore.firestore().collection("data").document("one").getDocument { (document, error) in
45+
if let document = document {
46+
let model = try! FirestoreDecoder().decode(Model.self, from: document.data())
47+
print("Model: \(model)")
48+
} else {
49+
print("Document does not exist")
50+
}
51+
}
52+
```

0 commit comments

Comments
 (0)