File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ function openDatabase() {
14
14
// that uses 'id' as its key
15
15
// and has an index called 'by-date', which is sorted
16
16
// by the 'time' property
17
+ return = idb . open ( 'wittr' , 1 , function ( upgradeDb ) {
18
+ var wittrs = upgradeDb . createObjectStore ( 'wittrs' , { keyPath : 'id' } ) ;
19
+ wittrs . createIndex ( 'by-date' , 'time' ) ;
20
+ } ) ;
17
21
}
18
22
19
23
export default function IndexController ( container ) {
@@ -135,7 +139,13 @@ IndexController.prototype._onSocketMessage = function(data) {
135
139
136
140
// TODO: put each message into the 'wittrs'
137
141
// object store.
142
+ var tx = db . transaction ( 'wittrs' , 'readwrite' ) ;
143
+ var wittrsStore = tx . objectStore ( 'wittrs' ) ;
144
+
145
+ messages . forEach ( function ( message ) {
146
+ wittrsStore . put ( message ) ;
147
+ } ) ;
138
148
} ) ;
139
149
140
150
this . _postsView . addPosts ( messages ) ;
141
- } ;
151
+ } ;
You can’t perform that action at this time.
0 commit comments