Skip to content

Module: Account

Аниса edited this page Jun 16, 2022 · 34 revisions

━ What's the Objective?

This module aims at providing Sequelize (ORM) inspired efficient & reliable MySQL management. All APIs are in the format of ORM to eliminate the extra hassle & worries regarding sql-injection. Additionally it comes w/ built in Async/Await support to avoid callback hells which can be used in conjunction w/ thread module!

━ APIs

⚠️ Disclaimer:

Syntax #2 should only be used in conjunction w/ thread

━ dbify.account.fetchAll() (Server)

@Objective: Fetches all existing accounts.
--Syntax #1:
local bool: state = dbify.account.fetchAll(
  table: {
    --These are conditional datas that has to be used for the query
    {string: columnName, ~: columnValue},
  },
  function: callback(table: result, table: arguments),
  ~: ...arguments
)

--Syntax #2:
local table: result, table: arguments = self:await(dbify.account.fetchAll(
  thread: self,
  table: {
    --These are conditional datas that has to be used for the query
    {string: columnName, ~: columnValue},
  },
  ~: ...arguments
))

━ dbify.account.create() (Server)

@Objective: Creates a new account.
dbify.account.create(accountName, callback(result, arguments)
    print(tostring(result))
    print(toJSON(arguments))
end, ...)

━ dbify.account.delete() (Server)

@Objective: Deletes an existing account.
dbify.account.delete(accountName, callback(result, arguments)
    print(tostring(result))
    print(toJSON(arguments))
end, ...)

━ dbify.account.setData() (Server)

@Objective: Sets account datas of a valid account.
dbify.account.setData(accountName, {
    --These are account datas to be updated
    {dataName1, dataValue1},
    {dataName2, dataValue2},
    ...
}, callback(result, arguments)
    print(tostring(result))
    print(toJSON(arguments))
end, ...)

━ dbify.account.getData() (Server)

@Objective: Retrieves account datas of a valid account.
dbify.account.getData(accountName, {
    --These are account datas to be retrieved
    dataName1,
    dataName2,
    ...
}, callback(result, arguments)
    print(toJSON(result))
    print(toJSON(arguments))
end, ...)
Clone this wiki locally