Skip to content

Commit 73ae085

Browse files
committed
moar!
1 parent 73fe52a commit 73ae085

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var schema = FirebaseSchema.create(Firebase, HOST, (child) => {
6161
- Now its easy to see what kind of data you save and where. Since the
6262
schema is defined as a nested route structure, we don't have to leave
6363
the key:value paradigm of Firebase.
64-
- Relationships via `index` and `key` get looked up for you
64+
- Relationships via `index` and `key` get looked up for you (https://www.firebase.com/docs/web/guide/structuring-data.html)
6565
- Data is validated when you try to `set` or `push` to a path.
6666
- `list`s are automatically converted to an array when you retrieve the
6767
value, with their keys assigned to `_id`.
@@ -74,7 +74,13 @@ var groupId;
7474

7575
usersRef.push({name: 'Ryan'}, () => {
7676
usersRef.getValue((err, val) => {
77-
console.log(val); // [{ name: 'Ryan', _id: 'flkajsdf' }]
77+
deepEqual(val, [{
78+
name: 'Ryan',
79+
// woah what's this? since we did `child('users', list, ...)`
80+
// we get the values back as an array with their firebase key
81+
// set as the `_id`
82+
_id: '-Jev95piCGXV9jX4ellH'
83+
}])
7884
userId = val[0]._id;
7985
});
8086
});
@@ -87,7 +93,7 @@ groupsRef.push({ name: 'cool kids table' }, () => {
8793
groupsRef.getValue((err, groups) => {
8894
groupId = groups[0]._id;
8995
// define a relationship between the group and the user using
90-
// a `key:true` index
96+
// a `key:true` index (https://www.firebase.com/docs/web/guide/structuring-data.html)
9197
groupsRef.child(`${groupId}/members/${userId}`).set(true);
9298
usersRef.child(`${userId}/groups/${groupId}`).set(true);
9399
});
@@ -96,11 +102,13 @@ groupsRef.push({ name: 'cool kids table' }, () => {
96102
// later
97103

98104
groupsRef.getValue((err, groups) => {
99-
console.log(groups[0]);
100105
deepEqual(groups[0], {
101106
name: 'cool kids table',
102107
_id: '-Jev95pjLLtDmIxbGhcF',
108+
// woah what's this?
103109
_indexes: {
110+
// because we defined `child('members', index(...))` we
111+
// get an array of paths to the members of this group
104112
members: [
105113
'users/-Jev95piCGXV9jX4ellH'
106114
]

0 commit comments

Comments
 (0)