Skip to content

Commit e262afe

Browse files
committed
docs: refactor
1 parent e96288b commit e262afe

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -57,45 +57,45 @@ query.subscribe(console.log);
5757

5858
## API
5959

60-
Better docs soon...
60+
Better docs soon, code is well-documented via typings...
6161

62-
### `init(app: FirebaseApp)`
62+
### `collection(path: string, query? QueryFn)`
6363

64-
Initializes the GeoFireClient
64+
Creates reference to a Firestore collection that can be used to make geo-queries and perform writes If you pass an optional Firestore query function, all subsequent geo-queries will be limited to this subset of documents
6565

66-
```ts
67-
import * as firebase from 'firebase/app';
68-
import * as geofirex from 'geofirex';
69-
firebase.initializeApp(yourConfig);
66+
Example:
7067

71-
const geo = geofirex.init(firebase);
68+
```
69+
const collection = geo.collection('cities', ref => ref.where('zip', '==', 90201) )
7270
```
7371

74-
### `collection`
72+
#### Performing Geo-Queries
7573

76-
Creates reference to a Firestore collection that can be used to make geo-queries and perform writes If you pass a query, any subsequent geo-queries will be limited to this subset of documents
74+
`collection.within(center: _GeoFirePoint_, radius: _`number`_, field: _`string`_, opts?: GeoQueryOptions):`Observable`<`object`[]>`
7775

78-
**Parameters:**
76+
Query by geographic distance. `within` queries parent Firestore collection for documents that exist within X kilometers of the centerpoint.
7977

80-
| Param | Type | Description |
81-
| ---------------- | -------- | ---------------------------- |
82-
| path | `string` | path to collection |
83-
| `Optional` query | QueryFn | callback for firestore query |
78+
Each doc also contains returns distance and bearing calculated on the query on the `queryMetadata` property.
8479

85-
#### collection.within(center: _GeoFirePoint_, radius: _`number`_, field: _`string`_, opts?: GeoQueryOptions): `Observable`<`object`[]>`
80+
**Returns:** `Observable`<`object`[]>
8681

87-
Queries the Firestore collection based on geograpic radius
82+
#### Write Data
8883

89-
**Parameters:**
84+
Write data just like you would in Firestore
9085

91-
| Param | Type | Default value | Description |
92-
| -------------------- | --------------- | ------------- | --------------------------------------------------------- |
93-
| center | GeoFirePoint | - | the starting point for the query, i.e geo.point(lat, lng) |
94-
| radius | `number` | - | the radius to search from the centerpoint |
95-
| field | `string` | - | the document field that contains the GeoFirePoint data |
96-
| `Default value` opts | GeoQueryOptions | defaultOpts |
86+
`collection.add(data)`
9787

98-
**Returns:** `Observable`<`object`[]>
88+
Or use one of the client's conveniece methods
89+
90+
- `collection.setDoc(id, data)` - Set a document in the collection with an ID.
91+
- `collection.setPoint(lat, lng)` - Non-destructive update with a GeoFirePoint
92+
93+
#### Read Data
94+
95+
In addition to Geo-Queries, you can also read the collection like you would normally in Firestore, but as an Observable
96+
97+
- `collection.data()`- Observable of document data
98+
- `collection.snapshot()`- Observable of Firestore QuerySnapshot
9999

100100
### `point`
101101

@@ -105,16 +105,16 @@ Returns a GeoFirePoint allowing you to create geohashes, format data, and calcul
105105

106106
#### Getters
107107

108-
- `hash` Returns a geohash string at precision 9
109-
- `geoPoint` Returns a Firestore GeoPoint
110-
- `geoJSON` Returns data as a GeoJSON `Feature<Point>`
111-
- `coords` Returns coordinates as `[latitude, longitude]`
112-
- `data` Returns data object suitable for saving to the Firestore database
108+
- `point.hash` Returns a geohash string at precision 9
109+
- `point.geoPoint` Returns a Firestore GeoPoint
110+
- `point.geoJSON` Returns data as a GeoJSON `Feature<Point>`
111+
- `point.coords` Returns coordinates as `[latitude, longitude]`
112+
- `point.data` Returns data object suitable for saving to the Firestore database
113113

114114
#### Geo Calculations
115115

116-
- `distance(latitude, longitude)` Haversine distance to a point
117-
- `bearing(latitude, longitude)` Haversine bearing to a point
116+
- `point.distance(latitude, longitude)` Haversine distance to a point
117+
- `point.bearing(latitude, longitude)` Haversine bearing to a point
118118

119119
## Tips
120120

0 commit comments

Comments
 (0)