-
Notifications
You must be signed in to change notification settings - Fork 1
/
players.lua
38 lines (33 loc) · 1015 Bytes
/
players.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
--- @entity players
--- @column id number NOT NULL AUTO_INCREMENT
--- @column nick string NOT NULL
--- @primaryKey id
local function createPlayersRepository()
--return exports.maku_sqlorm:createRepository('example/players.lua')
return createRepository('example/players.lua', GetCurrentResourceName())
end
PlayerRepository = createPlayersRepository()
Citizen.CreateThread(function()
local player = PlayerRepository:find('id', 1)
player.nick = 'adam'
local status, result = player.save()
end)
Citizen.CreateThread(function()
local player = PlayerRepository:createEntity({
nick = 'test'
})
player.save()
end)
Citizen.CreateThread(function()
local players = PlayerRepository:findAll()
for _, player in pairs(players) do
print(player.id, player.nick)
end
end)
Citizen.CreateThread(function()
PlayerRepository:findAllAsync(function(players)
for _, player in pairs(players) do
print(player.id, player.nick)
end
end)
end)