Skip to content

Commit 766970a

Browse files
committed
PR fixes
1 parent c5937b4 commit 766970a

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

skills/firestore-basics/references/android_sdk_usage.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This guide uses **Kotlin** and **KTX extensions**, which correspond to the moder
77
```kotlin
88
// In your Activity or Application class
99
import com.google.firebase.firestore.ktx.firestore
10+
import com.google.firebase.firestore.SetOptions
1011
import com.google.firebase.ktx.Firebase
1112

1213
val db = Firebase.firestore
@@ -73,7 +74,7 @@ db.runTransaction { transaction ->
7374
val snapshot = transaction.get(sfDocRef)
7475

7576
// Note: You can also use FieldValue.increment() for simple counters
76-
val newPopulation = snapshot.getDouble("population")!! + 1
77+
val newPopulation = (snapshot.getDouble("population") ?: 0.0) + 1
7778
transaction.update(sfDocRef, "population", newPopulation)
7879

7980
// Success
@@ -151,6 +152,6 @@ db.collection("cities")
151152

152153
```kotlin
153154
db.collection("cities")
154-
.orderBy("name", Query.Direction.KEY_ASCENDING)
155+
.orderBy("name", Query.Direction.ASCENDING)
155156
.limit(3)
156157
```

skills/firestore-basics/references/ios_sdk_usage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ db.collection("cities").document("LA").setData(city) { err in
4848
db.collection("cities").document("LA").setData([ "population": 3900000 ], merge: true)
4949
```
5050

51-
### Add a Document with Auto-ID (`addDocument`)
51+
###// Add a Document with Auto-ID (`addDocument`)
5252

5353
```swift
5454
var ref: DocumentReference? = nil
@@ -59,7 +59,7 @@ ref = db.collection("cities").addDocument(data: [
5959
if let err = err {
6060
print("Error adding document: \(err)")
6161
} else {
62-
print("Document added with ID: \(ref!.documentID)")
62+
print("Document added with ID: \(ref?.documentID ?? "unknown")")
6363
}
6464
}
6565
```
@@ -141,7 +141,7 @@ db.collection("cities").getDocuments() { (querySnapshot, err) in
141141
if let err = err {
142142
print("Error getting documents: \(err)")
143143
} else {
144-
for document in querySnapshot!.documents {
144+
for document in querySnapshot?.documents ?? [] {
145145
print("\(document.documentID) => \(document.data())")
146146
}
147147
}

skills/firestore-basics/references/provisioning.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,14 @@ Create a file named `firestore.indexes.json` with an empty configuration to star
7979

8080

8181
## Deploy rules and indexes
82-
To deploy all rules and indexes
83-
```
82+
```bash
83+
# To deploy all rules and indexes
8484
firebase deploy --only firestore
85-
```
86-
To deploy just rules
87-
```
85+
86+
# To deploy just rules
8887
firebase deploy --only firestore:rules
89-
```
90-
To deploy just indexes
91-
```
88+
89+
# To deploy just indexes
9290
firebase deploy --only firestore:indexes
9391
```
9492

skills/firestore-basics/references/security_rules.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ match /users/{userId} {
6565
### Allow only verified emails
6666
Requires users to verify ownership of the email address before using it to read or write data
6767
```
68-
match /databases/{database}/documents {
69-
// Allow access based on email domain
70-
match /some_collection/{document} {
71-
allow read: if request.auth != null
72-
&& request.auth.email_verified
73-
&& request.auth.email.endsWith('@example.com')
74-
}
75-
}
68+
// Allow access based on email domain
69+
match /some_collection/{document} {
70+
allow read: if request.auth != null
71+
&& request.auth.email_verified
72+
&& request.auth.email.endsWith('@example.com');
73+
}
7674
```
7775

7876
### Validate data in write operations

skills/firestore-basics/references/web_sdk_usage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ This guide focuses on the **Modular Web SDK** (v9+), which is tree-shakeable and
44

55
## Initialization
66

7+
```javascript
78
import { initializeApp } from "firebase/app";
89
import { getFirestore } from "firebase/firestore";
10+
```
911

1012
const firebaseConfig = {
1113
// Your config options. Get the values by running 'firebase apps:sdkconfig <platform> <app-id>'

0 commit comments

Comments
 (0)