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