Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 9874918

Browse files
Firestore anytime soon? #507 (doc)
1 parent d5aece4 commit 9874918

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

docs/FIRESTORE.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
<img src="https://raw.githubusercontent.com/EddyVerbruggen/nativescript-plugin-firebase/master/docs/images/features/firestore.png" height="85px" alt="Cloud Firestore"/>
22

3-
## Enabling the database features
3+
## Enabling Firestore
44
During plugin installation you'll be prompted to use either Firestore or the default DB.
55

6-
In case you're upgrading and you have the `firebase.nativescript.json` file in your project root,
7-
you can edit it and add: `"firestore": true`. Then do `rm -rf platforms/ios && rm -rf platforms/android && rm -rf node_modules && npm i`.
6+
In case you're upgrading and you have the `firebase.nativescript.json` file in your project root, edit it and add: `"firestore": true`. Then do `rm -rf platforms/ios && rm -rf platforms/android && rm -rf node_modules && npm i`.
87

98
## Functions
109
All of these are 100% compatible with the Firestore Web API to make it easy to share code between web and native, and you can
1110
refer to the [Firestore web api docs](https://firebase.google.com/docs/firestore/data-model) (make sure to look at the 'WEB' tab of those code samples).
1211

13-
> The plugin will take care of serializing JSON data to and from native data structures.
14-
1512
### `init` / `initializeApp`
1613
By default Firestore on iOS and Android persists data locally for offline usage (web doesn't by default, and the regular Firebase DB doesn't either on any platform).
1714
If you don't like that awesome feature, you can pass `persist: false` to the [`init` function](../README.md#init).
@@ -27,7 +24,7 @@ firebase.initializeApp({
2724
```
2825

2926
### `collection`
30-
A 'collection' is at the root of any Firestore interaction. Data is stored as 'documents' in a 'collection'.
27+
A 'collection' is at the root of any Firestore interaction. Data is stored as a 'document' inside a collection.
3128

3229
```typescript
3330
const citiesCollection = firebase.firestore().collection("cities");
@@ -47,21 +44,22 @@ citiesCollection.get().then(querySnapshot => {
4744
```
4845

4946
### `collection.doc()`
50-
A 'document' lives inside a 'collection' and contains the actual data:
47+
As mentioned, a document lives inside a collection and contains the actual data:
5148

5249
```typescript
53-
const sanFranciscoDocument = firebase.firestore().collection("cities").doc("SF");
50+
const citiesCollection = firebase.firestore().collection("cities");
51+
const sanFranciscoDocument = citiesCollection.doc("SF");
5452
```
5553

5654
### `collection.doc().get()`
57-
To get the data inside a document:
55+
To get the data inside a document (and check whether or not the document actually exists):
5856

5957
```typescript
6058
const sanFranciscoDocument = firebase.firestore().collection("cities").doc("SF");
6159

6260
sanFranciscoDocument.get().then(doc => {
6361
if (doc.exists) {
64-
console.log("Document data:", JSON.stringify(doc.data()));
62+
console.log(`Document data: ${JSON.stringify(doc.data())}`);
6563
} else {
6664
console.log("No such document!");
6765
}
@@ -81,7 +79,7 @@ citiesCollection.add({
8179
capital: false,
8280
population: 860000
8381
}).then(documentRef => {
84-
console.log("San Francisco added with auto-generated ID: " + documentRef.id);
82+
console.log(`San Francisco added with auto-generated ID: ${documentRef.id}`);
8583
});
8684
```
8785

@@ -173,4 +171,5 @@ query
173171
});
174172
```
175173

176-
> Need something that's not supported yet? Please open an Issue or PR 😚
174+
## Future work
175+
Need something that's not supported yet? Please open an Issue or PR 😚

0 commit comments

Comments
 (0)