@@ -10,10 +10,8 @@ server.js
10
10
11
11
``` js
12
12
13
- // Add 'hook' and 'onQuery' functions to the store
14
- derby .use (require (' sharedb-hooks' ));
15
- or
16
- racer .use (require (' sharedb-hooks' ));
13
+ // Add 'hook' and 'onQuery' functions to the backend
14
+ require (' sharedb-hooks' )(backend);
17
15
18
16
// ...
19
17
```
@@ -22,24 +20,24 @@ then you can use the function to hook model events, for example:
22
20
23
21
``` js
24
22
25
- store .hook (' create' , ' todos' , function (docId , value , session , backend ) {
26
- model = store .createModel ();
23
+ backend .hook (' create' , ' todos' , function (docId , value , session , backend ) {
24
+ model = backend .createModel ();
27
25
model .fetch (' todos.' + docId, function (err ){
28
26
var time = + new Date ();
29
27
model .set (' todos.' + docId+ ' .ctime' , time);
30
28
})
31
29
});
32
30
33
- store .hook (' change' , ' users.*.location' , function (docId , value , op , session , backend ){
34
- model = store .createModel ()
31
+ backend .hook (' change' , ' users.*.location' , function (docId , value , op , session , backend ){
32
+ model = backend .createModel ()
35
33
console .log (' User change location HOOK' );
36
34
37
35
// ....
38
36
39
37
});
40
38
41
- store .hook (' del' , ' todos' , function (docId , value , session , backend ) {
42
- model = store .createModel ();
39
+ backend .hook (' del' , ' todos' , function (docId , value , session , backend ) {
40
+ model = backend .createModel ();
43
41
44
42
// ....
45
43
@@ -48,6 +46,6 @@ then you can use the function to hook model events, for example:
48
46
49
47
```
50
48
51
- ## MIT License 2015
49
+ ## MIT License 2016
52
50
53
51
0 commit comments