-
Notifications
You must be signed in to change notification settings - Fork 14
/
crud.lua
180 lines (140 loc) · 4.46 KB
/
crud.lua
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
--- Tarantool module for performing operations across the cluster
--
-- @module crud
local cfg = require('crud.cfg')
local insert = require('crud.insert')
local insert_many = require('crud.insert_many')
local replace = require('crud.replace')
local replace_many = require('crud.replace_many')
local get = require('crud.get')
local update = require('crud.update')
local upsert = require('crud.upsert')
local upsert_many = require('crud.upsert_many')
local delete = require('crud.delete')
local select = require('crud.select')
local truncate = require('crud.truncate')
local len = require('crud.len')
local count = require('crud.count')
local borders = require('crud.borders')
local utils = require('crud.common.utils')
local stats = require('crud.stats')
local readview = require('crud.readview')
local schema = require('crud.schema')
local storage_info = require('crud.storage_info')
local storage = require('crud.storage')
local crud = {}
-- @refer crud.version
-- @tfield string _VERSION
-- Module version.
crud._VERSION = require('crud.version')
--- CRUD operations.
-- @section crud
-- @refer insert.tuple
-- @function insert
crud.insert = stats.wrap(insert.tuple, stats.op.INSERT)
-- @refer insert.object
-- @function insert_object
crud.insert_object = stats.wrap(insert.object, stats.op.INSERT)
-- @refer insert_many.tuples
-- @function insert_many
crud.insert_many = stats.wrap(insert_many.tuples, stats.op.INSERT_MANY)
-- @refer insert_many.objects
-- @function insert_object_many
crud.insert_object_many = stats.wrap(insert_many.objects, stats.op.INSERT_MANY)
-- @refer get.call
-- @function get
crud.get = stats.wrap(get.call, stats.op.GET)
-- @refer replace.tuple
-- @function replace
crud.replace = stats.wrap(replace.tuple, stats.op.REPLACE)
-- @refer replace.object
-- @function replace_object
crud.replace_object = stats.wrap(replace.object, stats.op.REPLACE)
-- @refer replace_many.tuples
-- @function replace_many
crud.replace_many = stats.wrap(replace_many.tuples, stats.op.REPLACE_MANY)
-- @refer replace_many.objects
-- @function replace_object_many
crud.replace_object_many = stats.wrap(replace_many.objects, stats.op.REPLACE_MANY)
-- @refer update.call
-- @function update
crud.update = stats.wrap(update.call, stats.op.UPDATE)
-- @refer upsert.tuple
-- @function upsert
crud.upsert = stats.wrap(upsert.tuple, stats.op.UPSERT)
-- @refer upsert_many.tuples
-- @function upsert_many
crud.upsert_many = stats.wrap(upsert_many.tuples, stats.op.UPSERT_MANY)
-- @refer upsert_many.objects
-- @function upsert_object_many
crud.upsert_object_many = stats.wrap(upsert_many.objects, stats.op.UPSERT_MANY)
-- @refer upsert.object
-- @function upsert
crud.upsert_object = stats.wrap(upsert.object, stats.op.UPSERT)
-- @refer delete.call
-- @function delete
crud.delete = stats.wrap(delete.call, stats.op.DELETE)
-- @refer select.call
-- @function select
crud.select = stats.wrap(select.call, stats.op.SELECT)
-- @refer select.pairs
-- @function pairs
crud.pairs = stats.wrap(select.pairs, stats.op.SELECT, { pairs = true })
-- @refer utils.unflatten_rows
-- @function unflatten_rows
crud.unflatten_rows = utils.unflatten_rows
-- @refer truncate.call
-- @function truncate
crud.truncate = stats.wrap(truncate.call, stats.op.TRUNCATE)
-- @refer len.call
-- @function len
crud.len = stats.wrap(len.call, stats.op.LEN)
-- @refer count.call
-- @function count
crud.count = stats.wrap(count.call, stats.op.COUNT)
-- @refer borders.min
-- @function min
crud.min = stats.wrap(borders.min, stats.op.BORDERS)
-- @refer borders.max
-- @function max
crud.max = stats.wrap(borders.max, stats.op.BORDERS)
-- @refer utils.cut_rows
-- @function cut_rows
crud.cut_rows = utils.cut_rows
-- @refer utils.cut_objects
-- @function cut_objects
crud.cut_objects = utils.cut_objects
-- @refer cfg.cfg
-- @function cfg
crud.cfg = cfg.cfg
-- @refer stats.get
-- @function stats
crud.stats = stats.get
-- @refer stats.reset
-- @function reset_stats
crud.reset_stats = stats.reset
-- @refer storage_info.call
-- @function storage_info
crud.storage_info = storage_info.call
-- @refer readview.new
-- @function readview
crud.readview = readview.new
-- @refer schema.call
-- @function schema
crud.schema = schema.call
function crud.init_router()
rawset(_G, 'crud', crud)
end
function crud.stop_router()
rawset(_G, 'crud', nil)
end
--- Initializes crud on node
--
-- Exports all functions that are used for calls
-- and CRUD operations.
--
-- @function init
--
crud.init_storage = storage.init
crud.stop_storage = storage.stop
return crud