@steedos/service-fields-indexs 3.0.0-beta.98 → 3.0.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/collection-indexes/cfs.instances.files.index.js +40 -0
- package/collection-indexes/cms_categories.index.js +26 -0
- package/collection-indexes/cms_posts.index.js +34 -0
- package/collection-indexes/default_db.js +27 -8
- package/collection-indexes/flow_positions.index.js +60 -0
- package/collection-indexes/flow_roles.index.js +35 -0
- package/collection-indexes/flows.index.js +116 -0
- package/collection-indexes/forms.index.js +69 -0
- package/collection-indexes/instance_number_rules.index.js +26 -0
- package/collection-indexes/instance_record_queue.index.js +33 -0
- package/collection-indexes/instance_tasks.index.js +35 -51
- package/collection-indexes/instances.index.js +242 -0
- package/collection-indexes/organizations.index.js +88 -0
- package/collection-indexes/process_delegation_rules.index.js +26 -0
- package/collection-indexes/space_user_signs.index.js +26 -0
- package/collection-indexes/space_users.index.js +94 -0
- package/collection-indexes/spaces.index.js +50 -0
- package/collection-indexes/steedos_keyvalue.index.js +60 -0
- package/collection-indexes/users.index.js +145 -0
- package/collection-indexes/webhooks.index.js +29 -0
- package/collection-indexes/workflow_nav.index.js +37 -0
- package/package.json +2 -3
- package/package.service.js +4 -22
- package/meteor-collection-indexs/cfs.instances.files.object.js +0 -6
- package/meteor-collection-indexs/cms_categories.object.js +0 -15
- package/meteor-collection-indexs/cms_posts.object.js +0 -22
- package/meteor-collection-indexs/flow_positions.object.js +0 -34
- package/meteor-collection-indexs/flow_roles.object.js +0 -15
- package/meteor-collection-indexs/flows.object.js +0 -85
- package/meteor-collection-indexs/forms.object.js +0 -48
- package/meteor-collection-indexs/instance_number_rules.object.js +0 -8
- package/meteor-collection-indexs/instance_record_queue.object.js +0 -11
- package/meteor-collection-indexs/instances.object.js +0 -221
- package/meteor-collection-indexs/organizations.object.js +0 -65
- package/meteor-collection-indexs/process_delegation_rules.object.js +0 -10
- package/meteor-collection-indexs/space_user_signs.object.js +0 -9
- package/meteor-collection-indexs/space_users.object.js +0 -74
- package/meteor-collection-indexs/spaces.object.js +0 -27
- package/meteor-collection-indexs/steedos_keyvalue.object.js +0 -45
- package/meteor-collection-indexs/users.object.js +0 -109
- package/meteor-collection-indexs/webhooks.object.js +0 -18
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// cfs_instances_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
// 获取 cfs.instances.files 集合
|
|
9
|
+
// 注意:根据实际情况调整集合名称
|
|
10
|
+
const collection = await getCollection('cfs_instances_files');
|
|
11
|
+
|
|
12
|
+
if (!collection) {
|
|
13
|
+
console.error('无法获取集合 cfs_instances_files');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 创建 metadata.instance 索引
|
|
18
|
+
await createIndexIfNotExists(collection, 'metadata_instance', {
|
|
19
|
+
"metadata.instance": 1
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// 创建 failures.copies.instances.doneTrying 索引
|
|
23
|
+
await createIndexIfNotExists(collection, 'failures_copies_instances_doneTrying', {
|
|
24
|
+
"failures.copies.instances.doneTrying": 1
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// 创建 copies.instances 索引
|
|
28
|
+
await createIndexIfNotExists(collection, 'copies_instances', {
|
|
29
|
+
"copies.instances": 1
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// 创建 uploadedAt 索引
|
|
33
|
+
await createIndexIfNotExists(collection, 'uploadedAt', {
|
|
34
|
+
"uploadedAt": 1
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
run
|
|
40
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// cms_categories_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
const collection = await getCollection('cms_categories');
|
|
9
|
+
|
|
10
|
+
if (!collection) {
|
|
11
|
+
console.error('无法获取集合 cms_categories');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 创建 site 和 parent 复合索引
|
|
16
|
+
await createIndexIfNotExists(collection, 'site_parent', {
|
|
17
|
+
"site": 1,
|
|
18
|
+
"parent": 1
|
|
19
|
+
}, {
|
|
20
|
+
background: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
run
|
|
26
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// cms_posts_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
const collection = await getCollection('cms_posts');
|
|
9
|
+
|
|
10
|
+
if (!collection) {
|
|
11
|
+
console.error('无法获取集合 cms_posts');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 创建 site 和 tags 复合索引
|
|
16
|
+
await createIndexIfNotExists(collection, 'site_tags', {
|
|
17
|
+
"site": 1,
|
|
18
|
+
"tags": 1
|
|
19
|
+
}, {
|
|
20
|
+
background: true
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// 创建 site 和 category 复合索引
|
|
24
|
+
await createIndexIfNotExists(collection, 'site_category', {
|
|
25
|
+
"site": 1,
|
|
26
|
+
"category": 1
|
|
27
|
+
}, {
|
|
28
|
+
background: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
run
|
|
34
|
+
};
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: sunhaolin@hotoa.com
|
|
3
|
-
* @Date: 2023-01-10 11:35:36
|
|
4
|
-
* @LastEditors: sunhaolin@hotoa.com
|
|
5
|
-
* @LastEditTime: 2023-01-10 13:45:33
|
|
6
|
-
* @Description:
|
|
7
|
-
*/
|
|
8
1
|
const objectql = require('@steedos/objectql')
|
|
9
2
|
|
|
10
3
|
async function getCollection(collectionName) {
|
|
@@ -17,6 +10,32 @@ async function getCollection(collectionName) {
|
|
|
17
10
|
}
|
|
18
11
|
}
|
|
19
12
|
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 通用的索引创建函数
|
|
16
|
+
* @param {Object} collection - 集合对象
|
|
17
|
+
* @param {string} indexName - 索引名称
|
|
18
|
+
* @param {Object} indexFields - 索引字段对象
|
|
19
|
+
* @param {Object} options - 索引选项,默认为 { background: true }
|
|
20
|
+
*/
|
|
21
|
+
async function createIndexIfNotExists(collection, indexName, indexFields, options = { background: true }) {
|
|
22
|
+
try {
|
|
23
|
+
indexName = `c2_${indexName}`;
|
|
24
|
+
const indexExists = await collection.indexExists(indexName)
|
|
25
|
+
if (!indexExists) {
|
|
26
|
+
const indexOptions = { ...options, name: indexName }
|
|
27
|
+
await collection.createIndex(indexFields, indexOptions)
|
|
28
|
+
console.log(`索引 ${indexName} 创建成功`)
|
|
29
|
+
} else {
|
|
30
|
+
// console.log(`索引 ${indexName} 已存在`)
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(`创建索引 ${indexName} 时出错:`, error)
|
|
34
|
+
throw error // 可以选择重新抛出错误或静默处理
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
20
38
|
module.exports = {
|
|
21
|
-
getCollection
|
|
39
|
+
getCollection,
|
|
40
|
+
createIndexIfNotExists
|
|
22
41
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// flow_positions_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
const collection = await getCollection('flow_positions');
|
|
9
|
+
|
|
10
|
+
if (!collection) {
|
|
11
|
+
console.error('无法获取集合 flow_positions');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 创建 space 和 created 复合索引
|
|
16
|
+
await createIndexIfNotExists(collection, 'space_created', {
|
|
17
|
+
"space": 1,
|
|
18
|
+
"created": 1
|
|
19
|
+
}, {
|
|
20
|
+
background: true
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// 创建 space、created 和 modified 复合索引
|
|
24
|
+
await createIndexIfNotExists(collection, 'space_created_modified', {
|
|
25
|
+
"space": 1,
|
|
26
|
+
"created": 1,
|
|
27
|
+
"modified": 1
|
|
28
|
+
}, {
|
|
29
|
+
background: true
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// 创建 role、org 和 space 复合索引
|
|
33
|
+
await createIndexIfNotExists(collection, 'role_org_space', {
|
|
34
|
+
"role": 1,
|
|
35
|
+
"org": 1,
|
|
36
|
+
"space": 1
|
|
37
|
+
}, {
|
|
38
|
+
background: true
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// 创建 space 和 users 复合索引
|
|
42
|
+
await createIndexIfNotExists(collection, 'space_users', {
|
|
43
|
+
"space": 1,
|
|
44
|
+
"users": 1
|
|
45
|
+
}, {
|
|
46
|
+
background: true
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// 创建 space 和 role 复合索引
|
|
50
|
+
await createIndexIfNotExists(collection, 'space_role', {
|
|
51
|
+
"space": 1,
|
|
52
|
+
"role": 1
|
|
53
|
+
}, {
|
|
54
|
+
background: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
run
|
|
60
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// flow_roles_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
const collection = await getCollection('flow_roles');
|
|
9
|
+
|
|
10
|
+
if (!collection) {
|
|
11
|
+
console.error('无法获取集合 flow_roles');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 创建 space 和 created 复合索引
|
|
16
|
+
await createIndexIfNotExists(collection, 'space_created', {
|
|
17
|
+
"space": 1,
|
|
18
|
+
"created": 1
|
|
19
|
+
}, {
|
|
20
|
+
background: true
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// 创建 space、created 和 modified 复合索引
|
|
24
|
+
await createIndexIfNotExists(collection, 'space_created_modified', {
|
|
25
|
+
"space": 1,
|
|
26
|
+
"created": 1,
|
|
27
|
+
"modified": 1
|
|
28
|
+
}, {
|
|
29
|
+
background: true
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
run
|
|
35
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// flows_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
const collection = await getCollection('flows');
|
|
9
|
+
|
|
10
|
+
if (!collection) {
|
|
11
|
+
console.error('无法获取集合 flows');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 创建 space 和 is_deleted 复合索引
|
|
16
|
+
await createIndexIfNotExists(collection, 'space_is_deleted', {
|
|
17
|
+
"space": 1,
|
|
18
|
+
"is_deleted": 1
|
|
19
|
+
}, {
|
|
20
|
+
background: true
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// 创建 role 和 is_deleted 复合索引
|
|
24
|
+
await createIndexIfNotExists(collection, 'role_is_deleted', {
|
|
25
|
+
"role": 1,
|
|
26
|
+
"is_deleted": 1
|
|
27
|
+
}, {
|
|
28
|
+
background: true
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// 创建 space、app 和 created 复合索引
|
|
32
|
+
await createIndexIfNotExists(collection, 'space_app_created', {
|
|
33
|
+
"space": 1,
|
|
34
|
+
"app": 1,
|
|
35
|
+
"created": 1
|
|
36
|
+
}, {
|
|
37
|
+
background: true
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// 创建 space、app、created 和 current.modified 复合索引
|
|
41
|
+
await createIndexIfNotExists(collection, 'space_app_created_current_modified', {
|
|
42
|
+
"space": 1,
|
|
43
|
+
"app": 1,
|
|
44
|
+
"created": 1,
|
|
45
|
+
"current.modified": 1
|
|
46
|
+
}, {
|
|
47
|
+
background: true
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 创建 name 和 space 复合索引
|
|
51
|
+
await createIndexIfNotExists(collection, 'name_space', {
|
|
52
|
+
"name": 1,
|
|
53
|
+
"space": 1
|
|
54
|
+
}, {
|
|
55
|
+
background: true
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// 创建 form 和 is_deleted 复合索引
|
|
59
|
+
await createIndexIfNotExists(collection, 'form_is_deleted', {
|
|
60
|
+
"form": 1,
|
|
61
|
+
"is_deleted": 1
|
|
62
|
+
}, {
|
|
63
|
+
background: true
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// 创建 current.steps.approver_roles、space 和 is_deleted 复合索引
|
|
67
|
+
await createIndexIfNotExists(collection, 'approver_roles_space_is_deleted', {
|
|
68
|
+
"current.steps.approver_roles": 1,
|
|
69
|
+
"space": 1,
|
|
70
|
+
"is_deleted": 1
|
|
71
|
+
}, {
|
|
72
|
+
background: true
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// 创建 _id、space 和 is_deleted 复合索引
|
|
76
|
+
await createIndexIfNotExists(collection, 'id_space_is_deleted', {
|
|
77
|
+
"_id": 1,
|
|
78
|
+
"space": 1,
|
|
79
|
+
"is_deleted": 1
|
|
80
|
+
}, {
|
|
81
|
+
background: true
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// 创建 space 和 form 复合索引
|
|
85
|
+
await createIndexIfNotExists(collection, 'space_form', {
|
|
86
|
+
"space": 1,
|
|
87
|
+
"form": 1
|
|
88
|
+
}, {
|
|
89
|
+
background: true
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// 创建 form 单字段索引(使用 try-catch 处理可能的错误)
|
|
93
|
+
try {
|
|
94
|
+
await createIndexIfNotExists(collection, 'form', {
|
|
95
|
+
"form": 1
|
|
96
|
+
}, {
|
|
97
|
+
background: true
|
|
98
|
+
});
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.warn('创建 form 索引时出错:', error.message);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 创建 space、form 和 state 复合索引
|
|
104
|
+
// 注意:原代码中 state: 后面有冒号,这里修正为 state
|
|
105
|
+
await createIndexIfNotExists(collection, 'space_form_state', {
|
|
106
|
+
"space": 1,
|
|
107
|
+
"form": 1,
|
|
108
|
+
"state": 1
|
|
109
|
+
}, {
|
|
110
|
+
background: true
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
module.exports = {
|
|
115
|
+
run
|
|
116
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// forms_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
const collection = await getCollection('forms');
|
|
9
|
+
|
|
10
|
+
if (!collection) {
|
|
11
|
+
console.error('无法获取集合 forms');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 创建 space 和 is_deleted 复合索引
|
|
16
|
+
await createIndexIfNotExists(collection, 'space_is_deleted', {
|
|
17
|
+
"space": 1,
|
|
18
|
+
"is_deleted": 1
|
|
19
|
+
}, {
|
|
20
|
+
background: true
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// 创建 space、app 和 created 复合索引
|
|
24
|
+
await createIndexIfNotExists(collection, 'space_app_created', {
|
|
25
|
+
"space": 1,
|
|
26
|
+
"app": 1,
|
|
27
|
+
"created": 1
|
|
28
|
+
}, {
|
|
29
|
+
background: true
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// 创建 space、app、created 和 current.modified 复合索引
|
|
33
|
+
await createIndexIfNotExists(collection, 'space_app_created_current_modified', {
|
|
34
|
+
"space": 1,
|
|
35
|
+
"app": 1,
|
|
36
|
+
"created": 1,
|
|
37
|
+
"current.modified": 1
|
|
38
|
+
}, {
|
|
39
|
+
background: true
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// 创建 name 和 space 复合索引
|
|
43
|
+
await createIndexIfNotExists(collection, 'name_space', {
|
|
44
|
+
"name": 1,
|
|
45
|
+
"space": 1
|
|
46
|
+
}, {
|
|
47
|
+
background: true
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 创建 _id 和 space 复合索引
|
|
51
|
+
await createIndexIfNotExists(collection, 'id_space', {
|
|
52
|
+
"_id": 1,
|
|
53
|
+
"space": 1
|
|
54
|
+
}, {
|
|
55
|
+
background: true
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// 创建 space 和 state 复合索引
|
|
59
|
+
await createIndexIfNotExists(collection, 'space_state', {
|
|
60
|
+
"space": 1,
|
|
61
|
+
"state": 1
|
|
62
|
+
}, {
|
|
63
|
+
background: true
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
run
|
|
69
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// instance_number_rules_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
const collection = await getCollection('instance_number_rules');
|
|
9
|
+
|
|
10
|
+
if (!collection) {
|
|
11
|
+
console.error('无法获取集合 instance_number_rules');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 创建 space 和 name 复合索引
|
|
16
|
+
await createIndexIfNotExists(collection, 'space_name', {
|
|
17
|
+
"space": 1,
|
|
18
|
+
"name": 1
|
|
19
|
+
}, {
|
|
20
|
+
background: true
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
run
|
|
26
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// instance_record_queue_indexes.js
|
|
2
|
+
const {
|
|
3
|
+
createIndexIfNotExists,
|
|
4
|
+
getCollection
|
|
5
|
+
} = require('./default_db');
|
|
6
|
+
|
|
7
|
+
async function run() {
|
|
8
|
+
const collection = await getCollection('instance_record_queue');
|
|
9
|
+
|
|
10
|
+
if (!collection) {
|
|
11
|
+
console.error('无法获取集合 instance_record_queue');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 创建 createdAt 单字段索引
|
|
16
|
+
await createIndexIfNotExists(collection, 'createdAt', {
|
|
17
|
+
"createdAt": 1
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// 创建 sent 单字段索引
|
|
21
|
+
await createIndexIfNotExists(collection, 'sent', {
|
|
22
|
+
"sent": 1
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// 创建 sending 单字段索引
|
|
26
|
+
await createIndexIfNotExists(collection, 'sending', {
|
|
27
|
+
"sending": 1
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
run
|
|
33
|
+
};
|
|
@@ -5,63 +5,47 @@
|
|
|
5
5
|
* @LastEditTime: 2023-08-27 11:00:46
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const {
|
|
9
|
+
createIndexIfNotExists,
|
|
10
|
+
getCollection
|
|
11
|
+
} = require('./default_db');
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
async function run() {
|
|
12
|
-
const collection = await
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const indexExists = await collection.indexExists(indexName)
|
|
18
|
-
if (!indexExists) {
|
|
19
|
-
await collection.createIndex({
|
|
20
|
-
handler: 1,
|
|
21
|
-
is_finished: 1,
|
|
22
|
-
space: 1,
|
|
23
|
-
start_date: -1,
|
|
24
|
-
category: 1,
|
|
25
|
-
is_deleted: 1,
|
|
26
|
-
}, { background: true, name: indexName })
|
|
27
|
-
}
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.error(error)
|
|
30
|
-
}
|
|
31
|
-
// 已审核箱
|
|
32
|
-
try {
|
|
33
|
-
const indexName = 'outbox'
|
|
34
|
-
const indexExists = await collection.indexExists(indexName)
|
|
35
|
-
if (!indexExists) {
|
|
36
|
-
await collection.createIndex({
|
|
37
|
-
handler: 1,
|
|
38
|
-
is_finished: 1,
|
|
39
|
-
space: 1,
|
|
40
|
-
finish_date: -1,
|
|
41
|
-
category: 1,
|
|
42
|
-
is_deleted: 1,
|
|
43
|
-
}, { background: true, name: indexName })
|
|
44
|
-
}
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.error(error)
|
|
15
|
+
const collection = await getCollection('instance_tasks')
|
|
16
|
+
|
|
17
|
+
if (!collection) {
|
|
18
|
+
console.error('无法获取集合 instance_tasks')
|
|
19
|
+
return
|
|
47
20
|
}
|
|
48
21
|
|
|
22
|
+
// 待审核箱索引
|
|
23
|
+
await createIndexIfNotExists(collection, 'inbox', {
|
|
24
|
+
handler: 1,
|
|
25
|
+
is_finished: 1,
|
|
26
|
+
space: 1,
|
|
27
|
+
start_date: -1,
|
|
28
|
+
category: 1,
|
|
29
|
+
is_deleted: 1,
|
|
30
|
+
})
|
|
49
31
|
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
32
|
+
// 已审核箱索引
|
|
33
|
+
await createIndexIfNotExists(collection, 'outbox', {
|
|
34
|
+
handler: 1,
|
|
35
|
+
is_finished: 1,
|
|
36
|
+
space: 1,
|
|
37
|
+
finish_date: -1,
|
|
38
|
+
category: 1,
|
|
39
|
+
is_deleted: 1,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// 推送badge计算索引
|
|
43
|
+
await createIndexIfNotExists(collection, 'push_badge', {
|
|
44
|
+
handler: 1,
|
|
45
|
+
is_finished: 1,
|
|
46
|
+
space: 1,
|
|
47
|
+
category: 1,
|
|
48
|
+
})
|
|
65
49
|
}
|
|
66
50
|
|
|
67
51
|
module.exports = {
|