-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlua.code-snippets
More file actions
68 lines (62 loc) · 1.81 KB
/
lua.code-snippets
File metadata and controls
68 lines (62 loc) · 1.81 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
//lua
"localp开头": {
"prefix": ["lua"],
"body": [
"local p = {}",
"function p.${1:render}(frame)",
"local args = frame.args",
"$0",
"end",
"return p",
],
"description": "lua常用开头",
"scope":"lua"
},
"findOne函数":{
"prefix": "findOne",
"body": [
"local ${1:tQuery} = {",
" _id = { [\"$$regex\"] = \"^Data:$2\\.${3|tabx,json,tab|}\"}",
" id = $4 }",
"local ${5:tOptions} = {",
" ['projection'] = {",
" ['${6:id}'] = 1,",
" $7",
" },",
"}",
"local data = mw.huiji.db.findOne(${1:tQuery},${5:tOptions})",
"$0",
],
"description": "findOne函数:用于查找一行的tabx文件",
"scope":"lua"
},
"find函数":{
"prefix": "find",
"body": [
"local ${1:tQuery} = {",
" _id = { [\"$$regex\"] = \"^Data:$2\\.${3|tabx,json,tab|}\"}",
" id = $4 }",
"local ${5:tOptions} = {",
" ['projection'] = {",
" ['${6:id}'] = 1,",
" $7",
" },",
" ['sort'] = {",
" ['index] = 1,",
"}",
"local data = mw.huiji.db.find(${1:tQuery},${5:tOptions})",
"$0",
],
"description": "find函数:用于查找数据",
"scope":"lua"
},
"调用函数":{
"prefix": "require",
"body": [
"local $1 = require('module:$2').$3",
],
"description": "调用其他模块:local 对象名 = require('module:模块名').函数名",
"scope":"lua"
},
}