Comparison

doc/storage.tld @ 7744:4d9186d990a5

doc: Add a description of the Storage API in TypedLua format
author Kim Alvefur <zash@zash.se>
date Sat, 26 Nov 2016 20:10:40 +0100
child 9903:2c5546cc5c70
comparison
equal deleted inserted replaced
7743:d018ffc9238c 7744:4d9186d990a5
1 -- Storage Interface API Description
2 --
3 -- This is written as a TypedLua description
4
5 -- Key-Value stores (the default)
6
7 interface keyval_store
8 get : ( self, string? ) -> (any) | (nil, string)
9 set : ( self, string?, any ) -> (boolean) | (nil, string)
10 end
11
12 -- Map stores (key-key-value stores)
13
14 interface map_store
15 get : ( self, string?, any ) -> (any) | (nil, string)
16 set : ( self, string?, any, any ) -> (boolean) | (nil, string)
17 set_keys : ( self, string?, { any : any }) -> (boolean) | (nil, string)
18 remove : {}
19 end
20
21 -- Archive stores
22
23 typealias archive_query = {
24 "start" : number?, -- timestamp
25 "end" : number?, -- timestamp
26 "with" : string?,
27 "after" : string?, -- archive id
28 "before" : string?, -- archive id
29 "total" : boolean?,
30 }
31
32 interface archive_store
33 -- Optional set of capabilities
34 caps : {
35 -- Optional total count of matching items returned as second return value from :find()
36 "total" : boolean?,
37 }?
38
39 -- Add to the archive
40 append : ( self, string?, string?, any, number?, string? ) -> (string) | (nil, string)
41
42 -- Iterate over archive
43 find : ( self, string?, archive_query? ) -> ( () -> ( string, any, number?, string? ), integer? )
44
45 -- Removal of items. API like find. Optional?
46 delete : ( self, string?, archive_query? ) -> (boolean) | (number) | (nil, string)
47
48 -- Array of dates which do have messages (Optional?)
49 dates : ( self, string? ) -> ({ string }) | (nil, string)
50 end
51
52 -- This represents moduleapi
53 interface module
54 -- If the first string is omitted then the name of the module is used
55 -- The second string is one of "keyval" (default), "map" or "archive"
56 open_store : (self, string?, string?) -> (keyval_store) | (map_store) | (archive_store) | (nil, string)
57
58 -- Other module methods omitted
59 end
60
61 module : module