File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -79,4 +79,15 @@ export class LocalStorage extends StorageEngine {
79
79
}
80
80
} ) ;
81
81
}
82
+
83
+ clear ( ) : Promise < any > {
84
+ return new Promise ( ( resolve , reject ) => {
85
+ try {
86
+ window . localStorage . clear ( ) ;
87
+ resolve ( ) ;
88
+ } catch ( e ) {
89
+ reject ( e ) ;
90
+ }
91
+ } ) ;
92
+ }
82
93
}
Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ export class SqlStorage extends StorageEngine {
142
142
*/
143
143
remove ( key : string ) : Promise < any > {
144
144
return this . query ( 'delete from kv where key = ?' , [ key ] ) ;
145
+ }
145
146
147
+ clear ( ) : Promise < any > {
148
+ return this . query ( 'delete from kv' ) ;
146
149
}
147
150
}
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ export class Storage {
51
51
query ( query : string , params ?: any ) {
52
52
return this . _strategy . query ( query , params ) ;
53
53
}
54
+
55
+ clear ( ) {
56
+ return this . _strategy . clear ( ) ;
57
+ }
54
58
}
55
59
56
60
export interface IStorageEngine {
@@ -75,4 +79,7 @@ export class StorageEngine {
75
79
query ( query : string , params ?: any ) : Promise < any > {
76
80
throw Error ( "query() not implemented for this storage engine" ) ;
77
81
}
82
+ clear ( ) : Promise < any > {
83
+ throw Error ( "clear() not implemented for this storage engine" ) ;
84
+ }
78
85
}
You can’t perform that action at this time.
0 commit comments