Skip to content

Commit bafa285

Browse files
* feat(types): add firestore `collectionGroup` type - prescottprue#855 - @rscotten * chore(docs): add note about `useFirestoreForProfile` within profile recipes - prescottprue#849 Co-authored-by: Richard Scotten <rscotten@users.noreply.github.com>
1 parent 31721a7 commit bafa285

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

docs/recipes/profile.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ Profile object is used to store data associated with a user. Using profile is in
66

77
It is common to store the list of user profiles under a collection called "users" or "profiles". For this example we will use "users".
88

9-
Include the `userProfile` parameter in config when setting up store enhancer:
9+
Include the `userProfile` parameter in config passed to react-redux-firebase:
1010

1111
```js
1212
const config = {
1313
userProfile: 'users', // where profiles are stored in database
1414
}
1515
```
1616

17-
### Using useSelector Hook
17+
### Get Profile From State
18+
19+
#### Using useSelector Hook
1820

1921
Then later `connect` (from [react-redux](https://github.com/reactjs/react-redux/blob/master/docs/api.md)) to redux state with:
2022

@@ -32,7 +34,7 @@ function SomeComponent() {
3234
}
3335
```
3436

35-
### Using connect HOC
37+
#### Using connect HOC
3638

3739
Then later `connect` (from [react-redux](https://github.com/reactjs/react-redux/blob/master/docs/api.md)) to redux state with:
3840

@@ -52,6 +54,17 @@ connect(
5254
connect(({ firebase: { profile } }) => ({ profile }))(SomeComponent)
5355
```
5456

57+
## Profile in Firestore
58+
59+
To use Firestore for storing profile data instead of Real Time Database, the basic example can be followed exactly with the following config.
60+
61+
```js
62+
const config = {
63+
userProfile: 'users', // where profiles are stored in database
64+
useFirestoreForProfile: true // use Firestore for profile instead of RTDB
65+
}
66+
```
67+
5568
## Update Profile
5669

5770
The current users profile can be updated by using the `updateProfile` method:
@@ -109,11 +122,14 @@ const config = {
109122
}
110123
```
111124

125+
This also works with profiles stored on Firestore if using the `useFirestoreForProfile` option
126+
112127
## List Online Users
113128

114129
To list online users and/or track sessions, view the [presence recipe](/docs/recipes/auth.md#presence)
115130

116131
## Populate Parameters
132+
117133
If profile object contains an key or a list of keys as parameters, you can populate those parameters with the matching value from another location on firebase.
118134

119135
#### List

index.d.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,12 @@ export interface ReduxFirestoreQuerySetting {
390390
* Collection name
391391
* @see https://github.com/prescottprue/redux-firestore#collection
392392
*/
393-
collection: string
393+
collection?: string
394+
/**
395+
* Collection Group name
396+
* @see https://github.com/prescottprue/redux-firestore#collection-group
397+
*/
398+
collectionGroup?: string
394399
/**
395400
* Document id
396401
* @see https://github.com/prescottprue/redux-firestore#document

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Components for use with React.",
55
"main": "lib/index.js",
66
"module": "es/index.js",

0 commit comments

Comments
 (0)