@k3000/store 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +123 -1
- package/architect.mjs +54 -2
- package/generator.mjs +67 -55
- package/package.json +1 -1
- package/test/1/buffer/683 +1 -0
- package/test/1/buffer/684 +1 -0
- package/test/1/data +0 -0
- package/test/1/index +0 -0
- package/test/2/buffer/683 +1 -0
- package/test/2/buffer/684 +1 -0
- package/test/2/data +0 -0
- package/test/2/index +0 -0
- package/test/2/index.mjs +25 -25
- package/test/2/type.ts +33 -33
- package/test/3/buffer/683 +1 -0
- package/test/3/buffer/684 +1 -0
- package/test/3/data +0 -0
- package/test/3/index +0 -0
- package/test/3/index.mjs +26 -26
- package/test/3/type.ts +33 -33
- package/test/4/buffer/683 +1 -0
- package/test/4/buffer/684 +1 -0
- package/test/4/data +0 -0
- package/test/4/index +0 -0
- package/test/4/index.mjs +26 -26
- package/test/4/type.ts +33 -33
- package/test/5/buffer/683 +1 -0
- package/test/5/buffer/684 +1 -0
- package/test/5/data +0 -0
- package/test/5/index +0 -0
- package/test/5/index.mjs +26 -26
- package/test/5/type.ts +33 -33
- package/test/6/buffer/683 +1 -0
- package/test/6/buffer/684 +1 -0
- package/test/6/data +0 -0
- package/test/6/index +0 -0
- package/test/6/index.mjs +11 -11
- package/test/6/type.ts +23 -23
- package/test/7/buffer/683 +1 -0
- package/test/7/buffer/684 +1 -0
- package/test/7/data +0 -0
- package/test/7/index +0 -0
- package/test/7/index.mjs +12 -12
- package/test/7/type.ts +23 -23
- package/test/8/buffer/683 +1 -0
- package/test/8/buffer/684 +1 -0
- package/test/8/data +0 -0
- package/test/8/index +0 -0
- package/test/8/index.mjs +12 -12
- package/test/8/type.ts +23 -23
- package/test/9/buffer/683 +1 -0
- package/test/9/buffer/684 +1 -0
- package/test/9/data +0 -0
- package/test/9/index +0 -0
- package/test/9/index.mjs +390 -0
- package/test/9/type.ts +174 -0
- package/test/index.mjs +3 -3
- package/test.mjs +98 -10
package/test/7/type.ts
CHANGED
|
@@ -5,22 +5,22 @@ interface Admin {
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
id: Number
|
|
8
|
-
/**
|
|
9
|
-
* 账号
|
|
10
|
-
*/
|
|
11
|
-
uid: String
|
|
12
8
|
/**
|
|
13
9
|
* 密码
|
|
14
10
|
*/
|
|
15
11
|
pwd: String
|
|
16
|
-
/**
|
|
17
|
-
* 是否有效
|
|
18
|
-
*/
|
|
19
|
-
valid: Number
|
|
20
12
|
/**
|
|
21
13
|
* 登录时间
|
|
22
14
|
*/
|
|
23
15
|
time: Number | Date
|
|
16
|
+
/**
|
|
17
|
+
* 账号
|
|
18
|
+
*/
|
|
19
|
+
uid: String
|
|
20
|
+
/**
|
|
21
|
+
* 是否有效
|
|
22
|
+
*/
|
|
23
|
+
valid: Number
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// @ts-ignore
|
|
@@ -58,26 +58,26 @@ interface AdminSet extends Array<Admin> {
|
|
|
58
58
|
|
|
59
59
|
interface Log {
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* 内容
|
|
63
|
+
*/
|
|
64
|
+
content: String
|
|
61
65
|
/**
|
|
62
66
|
*
|
|
63
67
|
*/
|
|
64
68
|
id: Number
|
|
65
69
|
/**
|
|
66
|
-
*
|
|
70
|
+
* 创建时间
|
|
67
71
|
*/
|
|
68
|
-
|
|
72
|
+
time: Number | Date
|
|
69
73
|
/**
|
|
70
74
|
* 类型
|
|
71
75
|
*/
|
|
72
76
|
type: Number
|
|
73
77
|
/**
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
time: Number | Date
|
|
77
|
-
/**
|
|
78
|
-
* 内容
|
|
78
|
+
* 账号
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
uid: String
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// @ts-ignore
|
|
@@ -115,11 +115,6 @@ interface LogSet extends Array<Log> {
|
|
|
115
115
|
|
|
116
116
|
interface Test3 {
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* 账
|
|
120
|
-
* 户
|
|
121
|
-
*/
|
|
122
|
-
uid: String
|
|
123
118
|
/**
|
|
124
119
|
*
|
|
125
120
|
*/
|
|
@@ -127,15 +122,20 @@ interface Test3 {
|
|
|
127
122
|
/**
|
|
128
123
|
*
|
|
129
124
|
*/
|
|
130
|
-
|
|
125
|
+
str: String
|
|
131
126
|
/**
|
|
132
127
|
*
|
|
133
128
|
*/
|
|
134
|
-
|
|
129
|
+
test: String
|
|
135
130
|
/**
|
|
136
131
|
*
|
|
137
132
|
*/
|
|
138
133
|
test2: String
|
|
134
|
+
/**
|
|
135
|
+
* 账
|
|
136
|
+
* 户
|
|
137
|
+
*/
|
|
138
|
+
uid: String
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// @ts-ignore
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
abc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
你好😊
|
package/test/8/data
CHANGED
|
Binary file
|
package/test/8/index
CHANGED
|
Binary file
|
package/test/8/index.mjs
CHANGED
|
@@ -5,16 +5,16 @@ import {struct} from '../../generator.mjs'
|
|
|
5
5
|
|
|
6
6
|
const storage = new Storage(import.meta.url)
|
|
7
7
|
|
|
8
|
+
const $content = 'content'
|
|
8
9
|
const $id = 'id'
|
|
9
|
-
const $uid = 'uid'
|
|
10
10
|
const $pwd = 'pwd'
|
|
11
|
-
const $valid = 'valid'
|
|
12
|
-
const $time = 'time'
|
|
13
|
-
const $type = 'type'
|
|
14
|
-
const $content = 'content'
|
|
15
|
-
const $test = 'test'
|
|
16
11
|
const $str = 'str'
|
|
12
|
+
const $test = 'test'
|
|
17
13
|
const $test2 = 'test2'
|
|
14
|
+
const $time = 'time'
|
|
15
|
+
const $type = 'type'
|
|
16
|
+
const $uid = 'uid'
|
|
17
|
+
const $valid = 'valid'
|
|
18
18
|
|
|
19
19
|
class Admin extends Entity {
|
|
20
20
|
|
|
@@ -237,21 +237,21 @@ class AdminSet extends Entities {
|
|
|
237
237
|
|
|
238
238
|
indexById(id, id_2) {
|
|
239
239
|
|
|
240
|
-
if (id_2 === undefined) return super.findByValue($id, uInt32BEToBuffer(id, $id))
|
|
240
|
+
if (id_2 === undefined || id == id_2) return super.findByValue($id, uInt32BEToBuffer(id, $id))
|
|
241
241
|
|
|
242
242
|
return super.findByRange($id, uInt32BEToBuffer(id, $id), uInt32BEToBuffer(id_2, $id))
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
indexByUid(uid, uid_2) {
|
|
246
246
|
|
|
247
|
-
if (uid_2 === undefined) return super.findByValue($uid, super.s2b(uid, $uid))
|
|
247
|
+
if (uid_2 === undefined || uid == uid_2) return super.findByValue($uid, super.s2b(uid, $uid))
|
|
248
248
|
|
|
249
249
|
return super.findByRange($uid, super.s2b(uid, $uid), super.s2b(uid_2, $uid))
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
indexByValid(valid, valid_2) {
|
|
253
253
|
|
|
254
|
-
if (valid_2 === undefined) return super.findByValue($valid, super.uintToBuffer(valid, $valid))
|
|
254
|
+
if (valid_2 === undefined || valid == valid_2) return super.findByValue($valid, super.uintToBuffer(valid, $valid))
|
|
255
255
|
|
|
256
256
|
return super.findByRange($valid, super.uintToBuffer(valid, $valid), super.uintToBuffer(valid_2, $valid))
|
|
257
257
|
}
|
|
@@ -305,21 +305,21 @@ class LogSet extends Entities {
|
|
|
305
305
|
|
|
306
306
|
indexById(id, id_2) {
|
|
307
307
|
|
|
308
|
-
if (id_2 === undefined) return super.findByValue($id, uInt32BEToBuffer(id, $id))
|
|
308
|
+
if (id_2 === undefined || id == id_2) return super.findByValue($id, uInt32BEToBuffer(id, $id))
|
|
309
309
|
|
|
310
310
|
return super.findByRange($id, uInt32BEToBuffer(id, $id), uInt32BEToBuffer(id_2, $id))
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
indexByUid(uid, uid_2) {
|
|
314
314
|
|
|
315
|
-
if (uid_2 === undefined) return super.findByValue($uid, super.s2b(uid, $uid))
|
|
315
|
+
if (uid_2 === undefined || uid == uid_2) return super.findByValue($uid, super.s2b(uid, $uid))
|
|
316
316
|
|
|
317
317
|
return super.findByRange($uid, super.s2b(uid, $uid), super.s2b(uid_2, $uid))
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
indexByType(type, type_2) {
|
|
321
321
|
|
|
322
|
-
if (type_2 === undefined) return super.findByValue($type, super.uintToBuffer(type, $type))
|
|
322
|
+
if (type_2 === undefined || type == type_2) return super.findByValue($type, super.uintToBuffer(type, $type))
|
|
323
323
|
|
|
324
324
|
return super.findByRange($type, super.uintToBuffer(type, $type), super.uintToBuffer(type_2, $type))
|
|
325
325
|
}
|
package/test/8/type.ts
CHANGED
|
@@ -5,22 +5,22 @@ interface Admin {
|
|
|
5
5
|
*
|
|
6
6
|
*/
|
|
7
7
|
id: Number
|
|
8
|
-
/**
|
|
9
|
-
* 账号
|
|
10
|
-
*/
|
|
11
|
-
uid: String
|
|
12
8
|
/**
|
|
13
9
|
* 密码
|
|
14
10
|
*/
|
|
15
11
|
pwd: String
|
|
16
|
-
/**
|
|
17
|
-
* 是否有效
|
|
18
|
-
*/
|
|
19
|
-
valid: Number
|
|
20
12
|
/**
|
|
21
13
|
* 登录时间
|
|
22
14
|
*/
|
|
23
15
|
time: Number | Date
|
|
16
|
+
/**
|
|
17
|
+
* 账号
|
|
18
|
+
*/
|
|
19
|
+
uid: String
|
|
20
|
+
/**
|
|
21
|
+
* 是否有效
|
|
22
|
+
*/
|
|
23
|
+
valid: Number
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// @ts-ignore
|
|
@@ -58,26 +58,26 @@ interface AdminSet extends Array<Admin> {
|
|
|
58
58
|
|
|
59
59
|
interface Log {
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* 内容
|
|
63
|
+
*/
|
|
64
|
+
content: String
|
|
61
65
|
/**
|
|
62
66
|
*
|
|
63
67
|
*/
|
|
64
68
|
id: Number
|
|
65
69
|
/**
|
|
66
|
-
*
|
|
70
|
+
* 创建时间
|
|
67
71
|
*/
|
|
68
|
-
|
|
72
|
+
time: Number | Date
|
|
69
73
|
/**
|
|
70
74
|
* 类型
|
|
71
75
|
*/
|
|
72
76
|
type: Number
|
|
73
77
|
/**
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
time: Number | Date
|
|
77
|
-
/**
|
|
78
|
-
* 内容
|
|
78
|
+
* 账号
|
|
79
79
|
*/
|
|
80
|
-
|
|
80
|
+
uid: String
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// @ts-ignore
|
|
@@ -115,11 +115,6 @@ interface LogSet extends Array<Log> {
|
|
|
115
115
|
|
|
116
116
|
interface Test3 {
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* 账
|
|
120
|
-
* 户
|
|
121
|
-
*/
|
|
122
|
-
uid: String
|
|
123
118
|
/**
|
|
124
119
|
*
|
|
125
120
|
*/
|
|
@@ -127,15 +122,20 @@ interface Test3 {
|
|
|
127
122
|
/**
|
|
128
123
|
*
|
|
129
124
|
*/
|
|
130
|
-
|
|
125
|
+
str: String
|
|
131
126
|
/**
|
|
132
127
|
*
|
|
133
128
|
*/
|
|
134
|
-
|
|
129
|
+
test: String
|
|
135
130
|
/**
|
|
136
131
|
*
|
|
137
132
|
*/
|
|
138
133
|
test2: String
|
|
134
|
+
/**
|
|
135
|
+
* 账
|
|
136
|
+
* 户
|
|
137
|
+
*/
|
|
138
|
+
uid: String
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
// @ts-ignore
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
abc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
你好😊
|
package/test/9/data
ADDED
|
Binary file
|
package/test/9/index
ADDED
|
Binary file
|
package/test/9/index.mjs
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
|
|
2
|
+
import {Entities, Entity, Storage, b2d, d2b, b2s, position, uInt32BEToBuffer, int32BEToBuffer,
|
|
3
|
+
doubleBEToBuffer, bigint32BEToBuffer, bigUint32BEToBuffer, readInt24BE, readUint24BE, Store, MaxTime} from '../../architect.mjs'
|
|
4
|
+
import {struct} from '../../generator.mjs'
|
|
5
|
+
|
|
6
|
+
const storage = new Storage(import.meta.url)
|
|
7
|
+
|
|
8
|
+
const $content = 'content'
|
|
9
|
+
const $id = 'id'
|
|
10
|
+
const $pwd = 'pwd'
|
|
11
|
+
const $str = 'str'
|
|
12
|
+
const $test = 'test'
|
|
13
|
+
const $test2 = 'test2'
|
|
14
|
+
const $time = 'time'
|
|
15
|
+
const $type = 'type'
|
|
16
|
+
const $uid = 'uid'
|
|
17
|
+
const $valid = 'valid'
|
|
18
|
+
|
|
19
|
+
class Admin extends Entity {
|
|
20
|
+
|
|
21
|
+
static name = 'admin'
|
|
22
|
+
|
|
23
|
+
static create(_) {
|
|
24
|
+
_.id = storage.updateValue(_.id, Admin.name, $id)
|
|
25
|
+
_.pwd = _.pwd || '123456'
|
|
26
|
+
_.time = _.time || new Date()
|
|
27
|
+
_.valid = _.valid || 0
|
|
28
|
+
return _
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
constructor(...arg) {
|
|
32
|
+
|
|
33
|
+
super(storage, ...arg)
|
|
34
|
+
|
|
35
|
+
return Object.defineProperties({}, {
|
|
36
|
+
[position]: {
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: false,
|
|
39
|
+
get: () => this[position],
|
|
40
|
+
},
|
|
41
|
+
id: {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: false,
|
|
44
|
+
get: () => super.get($id).readUInt32BE(0),
|
|
45
|
+
set: value => {
|
|
46
|
+
super.set2($id, uInt32BEToBuffer(value))
|
|
47
|
+
this.#update()
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
pwd: {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: false,
|
|
53
|
+
get: () => b2s(super.get($pwd)),
|
|
54
|
+
set: value => {
|
|
55
|
+
super.set($pwd, super.s2b(value, $pwd))
|
|
56
|
+
this.#update()
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
time: {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: false,
|
|
62
|
+
get: () => b2d(super.get($time)),
|
|
63
|
+
set: value => super.set2($time, d2b(value)),
|
|
64
|
+
},
|
|
65
|
+
uid: {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: false,
|
|
68
|
+
get: () => b2s(super.get($uid)),
|
|
69
|
+
set: value => {
|
|
70
|
+
super.set2($uid, super.s2b(value, $uid))
|
|
71
|
+
this.#update()
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
valid: {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: false,
|
|
77
|
+
get: () => super.get($valid).readUint8(0),
|
|
78
|
+
set: value => {
|
|
79
|
+
super.set2($valid, super.uintToBuffer(value, $valid))
|
|
80
|
+
this.#update()
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
#update() {
|
|
88
|
+
|
|
89
|
+
this.time = Date.now()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class Log extends Entity {
|
|
94
|
+
|
|
95
|
+
static name = 'log'
|
|
96
|
+
|
|
97
|
+
static create(_) {
|
|
98
|
+
_.id = storage.updateValue(_.id, Log.name, $id)
|
|
99
|
+
_.time = _.time || new Date()
|
|
100
|
+
return _
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
constructor(...arg) {
|
|
104
|
+
|
|
105
|
+
super(storage, ...arg)
|
|
106
|
+
|
|
107
|
+
return Object.defineProperties({}, {
|
|
108
|
+
[position]: {
|
|
109
|
+
enumerable: false,
|
|
110
|
+
configurable: false,
|
|
111
|
+
get: () => this[position],
|
|
112
|
+
},
|
|
113
|
+
content: {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
configurable: false,
|
|
116
|
+
get: () => b2s(super.get($content)),
|
|
117
|
+
set: value => super.set($content, super.s2b(value, $content)),
|
|
118
|
+
},
|
|
119
|
+
id: {
|
|
120
|
+
enumerable: true,
|
|
121
|
+
configurable: false,
|
|
122
|
+
get: () => super.get($id).readUInt32BE(0),
|
|
123
|
+
set: value => super.set2($id, uInt32BEToBuffer(value)),
|
|
124
|
+
},
|
|
125
|
+
time: {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: false,
|
|
128
|
+
get: () => b2d(super.get($time)),
|
|
129
|
+
set: value => super.set2($time, d2b(value)),
|
|
130
|
+
},
|
|
131
|
+
type: {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
configurable: false,
|
|
134
|
+
get: () => super.get($type).readUint16BE(0),
|
|
135
|
+
set: value => super.set($type, super.uintToBuffer(value, $type)),
|
|
136
|
+
},
|
|
137
|
+
uid: {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
configurable: false,
|
|
140
|
+
get: () => b2s(super.get($uid)),
|
|
141
|
+
set: value => super.set2($uid, super.s2b(value, $uid)),
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
class Test3 extends Entity {
|
|
149
|
+
|
|
150
|
+
static name = 'test3'
|
|
151
|
+
|
|
152
|
+
static create(_) {
|
|
153
|
+
|
|
154
|
+
return _
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
constructor(...arg) {
|
|
158
|
+
|
|
159
|
+
super(storage, ...arg)
|
|
160
|
+
|
|
161
|
+
return Object.defineProperties({}, {
|
|
162
|
+
[position]: {
|
|
163
|
+
enumerable: false,
|
|
164
|
+
configurable: false,
|
|
165
|
+
get: () => this[position],
|
|
166
|
+
},
|
|
167
|
+
pwd: {
|
|
168
|
+
enumerable: true,
|
|
169
|
+
configurable: false,
|
|
170
|
+
get: () => b2s(super.get($pwd)),
|
|
171
|
+
set: value => super.set($pwd, super.s2b(value, $pwd)),
|
|
172
|
+
},
|
|
173
|
+
str: {
|
|
174
|
+
enumerable: true,
|
|
175
|
+
configurable: false,
|
|
176
|
+
get: () => b2s(super.get($str)),
|
|
177
|
+
set: value => super.set($str, super.s2b(value, $str)),
|
|
178
|
+
},
|
|
179
|
+
test: {
|
|
180
|
+
enumerable: true,
|
|
181
|
+
configurable: false,
|
|
182
|
+
get: () => b2s(super.get($test)),
|
|
183
|
+
set: value => super.set($test, super.s2b(value, $test)),
|
|
184
|
+
},
|
|
185
|
+
test2: {
|
|
186
|
+
enumerable: true,
|
|
187
|
+
configurable: false,
|
|
188
|
+
get: () => b2s(super.get($test2)),
|
|
189
|
+
set: value => super.set($test2, super.s2b(value, $test2)),
|
|
190
|
+
},
|
|
191
|
+
uid: {
|
|
192
|
+
enumerable: true,
|
|
193
|
+
configurable: false,
|
|
194
|
+
get: () => b2s(super.get($uid)),
|
|
195
|
+
set: value => super.set($uid, super.s2b(value, $uid)),
|
|
196
|
+
},
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class AdminSet extends Entities {
|
|
204
|
+
|
|
205
|
+
constructor() {
|
|
206
|
+
|
|
207
|
+
super(storage, Admin)
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* 内部方法
|
|
211
|
+
*/
|
|
212
|
+
s2b() {
|
|
213
|
+
|
|
214
|
+
throw new TypeError('s2b is not a function')
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 内部方法
|
|
218
|
+
*/
|
|
219
|
+
findByValue() {
|
|
220
|
+
|
|
221
|
+
throw new TypeError('findByValue is not a function')
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* 内部方法
|
|
225
|
+
*/
|
|
226
|
+
findByTime() {
|
|
227
|
+
|
|
228
|
+
throw new TypeError('findByTime is not a function')
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* 内部方法
|
|
232
|
+
*/
|
|
233
|
+
stringToBuffer() {
|
|
234
|
+
|
|
235
|
+
throw new TypeError('stringToBuffer is not a function')
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
indexById(id, id_2) {
|
|
239
|
+
|
|
240
|
+
if (id_2 === undefined || id == id_2) return super.findByValue($id, uInt32BEToBuffer(id, $id))
|
|
241
|
+
|
|
242
|
+
return super.findByRange($id, uInt32BEToBuffer(id, $id), uInt32BEToBuffer(id_2, $id))
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
indexByUid(uid, uid_2) {
|
|
246
|
+
|
|
247
|
+
if (uid_2 === undefined || uid == uid_2) return super.findByValue($uid, super.s2b(uid, $uid))
|
|
248
|
+
|
|
249
|
+
return super.findByRange($uid, super.s2b(uid, $uid), super.s2b(uid_2, $uid))
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
indexByValid(valid, valid_2) {
|
|
253
|
+
|
|
254
|
+
if (valid_2 === undefined || valid == valid_2) return super.findByValue($valid, super.uintToBuffer(valid, $valid))
|
|
255
|
+
|
|
256
|
+
return super.findByRange($valid, super.uintToBuffer(valid, $valid), super.uintToBuffer(valid_2, $valid))
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
indexByTime(after = {}, before) {
|
|
260
|
+
|
|
261
|
+
if (typeof after === "object" && Reflect.has(after, 'before')) {
|
|
262
|
+
|
|
263
|
+
before = after.before
|
|
264
|
+
after = after.after
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return super.findByRange($time, d2b(after || 0), d2b(before || MaxTime))
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
class LogSet extends Entities {
|
|
272
|
+
|
|
273
|
+
constructor() {
|
|
274
|
+
|
|
275
|
+
super(storage, Log)
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* 内部方法
|
|
279
|
+
*/
|
|
280
|
+
s2b() {
|
|
281
|
+
|
|
282
|
+
throw new TypeError('s2b is not a function')
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* 内部方法
|
|
286
|
+
*/
|
|
287
|
+
findByValue() {
|
|
288
|
+
|
|
289
|
+
throw new TypeError('findByValue is not a function')
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* 内部方法
|
|
293
|
+
*/
|
|
294
|
+
findByTime() {
|
|
295
|
+
|
|
296
|
+
throw new TypeError('findByTime is not a function')
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* 内部方法
|
|
300
|
+
*/
|
|
301
|
+
stringToBuffer() {
|
|
302
|
+
|
|
303
|
+
throw new TypeError('stringToBuffer is not a function')
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
indexById(id, id_2) {
|
|
307
|
+
|
|
308
|
+
if (id_2 === undefined || id == id_2) return super.findByValue($id, uInt32BEToBuffer(id, $id))
|
|
309
|
+
|
|
310
|
+
return super.findByRange($id, uInt32BEToBuffer(id, $id), uInt32BEToBuffer(id_2, $id))
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
indexByUid(uid, uid_2) {
|
|
314
|
+
|
|
315
|
+
if (uid_2 === undefined || uid == uid_2) return super.findByValue($uid, super.s2b(uid, $uid))
|
|
316
|
+
|
|
317
|
+
return super.findByRange($uid, super.s2b(uid, $uid), super.s2b(uid_2, $uid))
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
indexByTime(after = {}, before) {
|
|
321
|
+
|
|
322
|
+
if (typeof after === "object" && Reflect.has(after, 'before')) {
|
|
323
|
+
|
|
324
|
+
before = after.before
|
|
325
|
+
after = after.after
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return super.findByRange($time, d2b(after || 0), d2b(before || MaxTime))
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
class Test3Set extends Entities {
|
|
333
|
+
|
|
334
|
+
constructor() {
|
|
335
|
+
|
|
336
|
+
super(storage, Test3)
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* 内部方法
|
|
340
|
+
*/
|
|
341
|
+
s2b() {
|
|
342
|
+
|
|
343
|
+
throw new TypeError('s2b is not a function')
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* 内部方法
|
|
347
|
+
*/
|
|
348
|
+
findByValue() {
|
|
349
|
+
|
|
350
|
+
throw new TypeError('findByValue is not a function')
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* 内部方法
|
|
354
|
+
*/
|
|
355
|
+
findByTime() {
|
|
356
|
+
|
|
357
|
+
throw new TypeError('findByTime is not a function')
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* 内部方法
|
|
361
|
+
*/
|
|
362
|
+
stringToBuffer() {
|
|
363
|
+
|
|
364
|
+
throw new TypeError('stringToBuffer is not a function')
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export const remark = Symbol('remark')
|
|
370
|
+
|
|
371
|
+
export const close = () => storage.close()
|
|
372
|
+
|
|
373
|
+
export const getStruct = name => struct(storage, remark, name)
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @type {import('./type').Storage}
|
|
377
|
+
*/
|
|
378
|
+
const store = Object.freeze({
|
|
379
|
+
admin: new Proxy([], {
|
|
380
|
+
get: new AdminSet()
|
|
381
|
+
}),
|
|
382
|
+
log: new Proxy([], {
|
|
383
|
+
get: new LogSet()
|
|
384
|
+
}),
|
|
385
|
+
test3: new Proxy([], {
|
|
386
|
+
get: new Test3Set()
|
|
387
|
+
}),
|
|
388
|
+
})
|
|
389
|
+
|
|
390
|
+
export default store
|