Skip to content

Commit dc9c291

Browse files
author
Olivier Bonnaure
committed
chores: replace \t by spaces
1 parent 85174b9 commit dc9c291

File tree

10 files changed

+1511
-1511
lines changed

10 files changed

+1511
-1511
lines changed

.lua/arango_model.lua

Lines changed: 348 additions & 348 deletions
Large diffs are not rendered by default.

.lua/db/crate.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ function Crate:sql(sql, bindVars)
2222
self._db_config["url"] .. "/_sql",
2323
{
2424
method = "POST",
25-
body = EncodeJson({ stmt= sql, bind_vars= bindVars }),
25+
body = EncodeJson({ stmt= sql, bind_vars= bindVars }) or "",
2626
headers = {
2727
["Accept"] = "application/json"
2828
}
2929
}
3030
)
3131

3232
if (ok == 200) then
33-
local response = DecodeJson(body)
33+
local response = DecodeJson(body) or {}
3434
local duration = response["duration"]
3535

3636
local data = {}
37-
local rows = response["rows"]
38-
local columns = response["cols"]
37+
local rows = response["rows"] or {}
38+
local columns = response["cols"] or {}
3939

4040
for j = 1, #rows do
41-
local row = response["rows"][j]
41+
local row = response["rows"][j] or {}
4242
local rowData = {}
4343
for k = 1, #columns do rowData[columns[k]] = row[k] end
4444
data[j] = rowData

.lua/db/db2rest.lua

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,95 @@ DB2Rest = {}
22
DB2Rest.__index = DB2Rest
33

44
function DB2Rest.new(db_config)
5-
local self = setmetatable({}, DB2Rest)
6-
self._db_config = db_config
7-
self._restApiUrl = db_config["url"] .. db_config["db_name"] .. "/"
5+
local self = setmetatable({}, DB2Rest)
6+
self._db_config = db_config
7+
self._restApiUrl = db_config["url"] .. db_config["db_name"] .. "/"
88

9-
return self
9+
return self
1010
end
1111

1212
function DB2Rest:read(collection, params, body)
13-
params = params or {}
14-
params['filters'] = params['filters'] or {}
15-
params['sort'] = params['sort'] or {}
16-
params['fields'] = params['fields'] or {}
13+
params = params or {}
14+
params['filters'] = params['filters'] or {}
15+
params['sort'] = params['sort'] or {}
16+
params['fields'] = params['fields'] or {}
1717

18-
local filter = "?filter=" .. table.concat(params['filters'], ";")
19-
filter = filter .. "&sort=" .. table.concat(params['sort'], ";")
20-
filter = filter .. "&fields=" .. table.concat(params['fields'], ",")
18+
local filter = "?filter=" .. table.concat(params['filters'], ";")
19+
filter = filter .. "&sort=" .. table.concat(params['sort'], ";")
20+
filter = filter .. "&fields=" .. table.concat(params['fields'], ",")
2121

22-
local method = "GET"
23-
local expand = ""
22+
local method = "GET"
23+
local expand = ""
2424

25-
local request_params = {
26-
method = method,
27-
headers = {
28-
["Content-Type"] = "application/json"
29-
}
30-
}
25+
local request_params = {
26+
method = method,
27+
headers = {
28+
["Content-Type"] = "application/json"
29+
}
30+
}
3131

32-
if body then
33-
request_params.body = EncodeJson(body) or ""
34-
method = "POST"
35-
expand = "/_expand"
36-
end
32+
if body then
33+
request_params.body = EncodeJson(body) or ""
34+
method = "POST"
35+
expand = "/_expand"
36+
end
3737

38-
local ok, h, body =
39-
Fetch(
40-
self._restApiUrl .. collection .. expand .. filter,
41-
request_params
42-
)
43-
return DecodeJson(body)
38+
local ok, h, body =
39+
Fetch(
40+
self._restApiUrl .. collection .. expand .. filter,
41+
request_params
42+
)
43+
return DecodeJson(body)
4444
end
4545

4646
function DB2Rest:write(collection, params)
47-
local ok, h, body =
48-
Fetch(
49-
self._restApiUrl .. collection .. filter,
50-
{
51-
method = "POST",
52-
body = EncodeJson(params) or "",
53-
headers = {
54-
["Content-Type"] = "application/json"
55-
}
56-
}
57-
)
58-
return DecodeJson(body)
47+
local ok, h, body =
48+
Fetch(
49+
self._restApiUrl .. collection .. filter,
50+
{
51+
method = "POST",
52+
body = EncodeJson(params) or "",
53+
headers = {
54+
["Content-Type"] = "application/json"
55+
}
56+
}
57+
)
58+
return DecodeJson(body)
5959
end
6060

6161
function DB2Rest:delete(collection, params)
62-
local ok, h, body =
63-
Fetch(
64-
self._restApiUrl .. collection .. filter,
65-
{
66-
method = "DELETE",
67-
body = EncodeJson(params) or "",
68-
headers = {
69-
["Content-Type"] = "application/json"
70-
}
71-
}
72-
)
73-
return DecodeJson(body)
62+
local ok, h, body =
63+
Fetch(
64+
self._restApiUrl .. collection .. filter,
65+
{
66+
method = "DELETE",
67+
body = EncodeJson(params) or "",
68+
headers = {
69+
["Content-Type"] = "application/json"
70+
}
71+
}
72+
)
73+
return DecodeJson(body)
7474
end
7575

7676
function DB2Rest:update(collection, filters, params)
77-
local filter = ""
78-
if type(filters) == "table" then
79-
filter = "?filter=" .. table.concat(filters, ";")
80-
end
77+
local filter = ""
78+
if type(filters) == "table" then
79+
filter = "?filter=" .. table.concat(filters, ";")
80+
end
8181

82-
local ok, h, body =
83-
Fetch(
84-
self._restApiUrl .. collection .. filter,
85-
{
86-
method = "PUT",
87-
body = EncodeJson(params) or "",
88-
headers = {
89-
["Content-Type"] = "application/json"
90-
}
91-
}
92-
)
93-
return DecodeJson(body)
82+
local ok, h, body =
83+
Fetch(
84+
self._restApiUrl .. collection .. filter,
85+
{
86+
method = "PUT",
87+
body = EncodeJson(params) or "",
88+
headers = {
89+
["Content-Type"] = "application/json"
90+
}
91+
}
92+
)
93+
return DecodeJson(body)
9494
end
9595

9696
return DB2Rest

.lua/db/postgrest.lua

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,57 @@ PGRest = {}
22
PGRest.__index = PGRest
33

44
function PGRest.new(db_config)
5-
local self = setmetatable({}, PGRest)
6-
self._db_config = db_config
7-
self._api_url = ""
8-
self._headers = {}
9-
self:init()
5+
local self = setmetatable({}, PGRest)
6+
self._db_config = db_config
7+
self._api_url = ""
8+
self._headers = {}
9+
self:init()
1010

11-
return self
11+
return self
1212
end
1313

1414
function PGRest:init()
15-
self._api_url = self._db_config["url"]
16-
self._headers = {
17-
["Authorization"] = "Bearer " .. self._db_config["jwt_token"],
18-
["Content-Type"] = "application/json"
19-
}
15+
self._api_url = self._db_config["url"]
16+
self._headers = {
17+
["Authorization"] = "Bearer " .. self._db_config["jwt_token"],
18+
["Content-Type"] = "application/json"
19+
}
2020
end
2121

2222
function PGRest:count(path)
23-
local ok, h, body = Fetch(self._api_url .. path, { headers = table.merge(self._headers, { Prefer = "count=exact" }) })
24-
return ok, tonumber(string.split(h["Content-Range"], "/")[2])
23+
local ok, h, body = Fetch(self._api_url .. path, { headers = table.merge(self._headers, { Prefer = "count=exact" }) })
24+
return ok, tonumber(string.split(h["Content-Range"], "/")[2])
2525
end
2626

2727
function PGRest:read(path)
28-
local ok, h, body = Fetch(self._api_url .. path, { headers = self._headers })
29-
return ok, DecodeJson(body)
28+
local ok, h, body = Fetch(self._api_url .. path, { headers = self._headers })
29+
return ok, DecodeJson(body)
3030
end
3131

3232
function PGRest:update(path, data)
33-
local ok, h, body = Fetch(self._api_url .. path, {
34-
method = "PATCH",
35-
body = data and EncodeJson(data) or {},
36-
headers = self._headers
37-
})
38-
return ok, DecodeJson(body)
33+
local ok, h, body = Fetch(self._api_url .. path, {
34+
method = "PATCH",
35+
body = data and EncodeJson(data) or {},
36+
headers = self._headers
37+
})
38+
return ok, DecodeJson(body)
3939
end
4040

4141
function PGRest:insert(path, data)
42-
local ok, h, body = Fetch(self._api_url .. path, {
43-
method = "POST",
44-
body = data and EncodeJson(data) or {},
45-
headers = table.merge(self._headers, { Prefer = "return=representation" })
46-
})
47-
return ok, body
42+
local ok, h, body = Fetch(self._api_url .. path, {
43+
method = "POST",
44+
body = data and EncodeJson(data) or {},
45+
headers = table.merge(self._headers, { Prefer = "return=representation" })
46+
})
47+
return ok, body
4848
end
4949

5050
function PGRest:delete(path, data)
51-
local ok, h, body = Fetch(self._api_url .. path, {
52-
method = "DELETE",
53-
headers = self._headers
54-
})
55-
return ok, DecodeJson(body)
51+
local ok, h, body = Fetch(self._api_url .. path, {
52+
method = "DELETE",
53+
headers = self._headers
54+
})
55+
return ok, DecodeJson(body)
5656
end
5757

5858
return PGRest

0 commit comments

Comments
 (0)