mm_store 1.0.0 → 1.0.1
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/index.js +10 -2
- package/package.json +40 -36
package/index.js
CHANGED
|
@@ -4,6 +4,14 @@ const Store = require('./lib/store');
|
|
|
4
4
|
const admin = new Admin();
|
|
5
5
|
admin.setClass(Store);
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* 作用域实例表
|
|
9
|
+
* @description 独立于 Admin 维护,避免 Admin.get() 将 config.name 覆盖为作用域名,
|
|
10
|
+
* 与 Store 用 config.name 表示"名称字段名"的语义发生冲突。
|
|
11
|
+
* @type {Map<string, Store>}
|
|
12
|
+
*/
|
|
13
|
+
const stores = new Map();
|
|
14
|
+
|
|
7
15
|
/**
|
|
8
16
|
* 获取指定作用域的存储实例,不存在时创建
|
|
9
17
|
* @param {string} [scope] 作用域名称,缺省时使用 os
|
|
@@ -14,10 +22,10 @@ function storeAdmin(scope, config) {
|
|
|
14
22
|
if (!scope) {
|
|
15
23
|
scope = 'os';
|
|
16
24
|
}
|
|
17
|
-
let store =
|
|
25
|
+
let store = stores.get(scope);
|
|
18
26
|
if (!store) {
|
|
19
27
|
store = new Store(config);
|
|
20
|
-
|
|
28
|
+
stores.set(scope, store);
|
|
21
29
|
}
|
|
22
30
|
return store;
|
|
23
31
|
}
|
package/package.json
CHANGED
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
"name": "mm_store",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "存储类:提供基于内存列表的增删改查、分页、关键词搜索与排序能力,支持自定义主键与过滤配置",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://gitee.com/qiuwenwu91/mm_store.git"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "node test.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mm_mod",
|
|
15
|
+
"mm_infra",
|
|
16
|
+
"mm_data",
|
|
17
|
+
"store",
|
|
18
|
+
"存储",
|
|
19
|
+
"列表",
|
|
20
|
+
"分页",
|
|
21
|
+
"搜索",
|
|
22
|
+
"排序"
|
|
23
|
+
],
|
|
24
|
+
"layer": "infra",
|
|
25
|
+
"group": "data",
|
|
26
|
+
"author": "邱文武",
|
|
27
|
+
"license": "ISC",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"mm_corejs": "^1.1.4"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=14.0.0"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"index.js",
|
|
36
|
+
"lib",
|
|
37
|
+
"example",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
]
|
|
41
|
+
}
|