Skip to content

Glossary: Module

Аниса edited this page Dec 18, 2022 · 6 revisions

━ What's the Objective?

Want to create your own modules instead of the ones we shipped within DBify? Panic no more, we've prepared support for custom modules already to suit various strategies!

Managing database never been easier: Specify your module structure & get the module ready in matter of seconds with all essential methods as noted down below inherited automatically for you to get started 😃.

━ APIs

━ dbify.createModule() (Server)

@Objective: Creates a fresh custom dbify module as per specified structure.
local table: cModule = dbify.createModule({
    moduleName = "yourModuleName", --Used for accessing module globally via `dbify.module.yourModuleName`
    tableName = "yourtablename", --Name of table to create for the specified module
    structure = {
        --Structure based on which the table shall be created
        {"id", "BIGINT AUTO_INCREMENT PRIMARY KEY"},
        {"name", "TEXT NOT NULL"},
        {"age", "INT"},
        {"country", "TEXT DEFAULT='N/A'"}
    }
})

━ Methods

━ cModule.fetchAll() (Server)

@Objective: Fetches all existing identities.
local table: result, table: arguments = cModule.fetchAll(
  table: {
    --Conditional datas to be used for the query
    {string: columnName, ~: columnValue},
    ...
  },
  bool: isSoloFetch, --Enabling this returns only first row of the retrieved result
  ~: ...arguments
)

━ cModule.create() (Server)

@Objective: Creates a new identity.
local bool: result, table: arguments = cModule.create(
  ~: ...values, --Values should be passed in the same order as specified within the structure; Primary key is omitted if its an auto incrementing key
  ~: ...arguments
)

━ cModule.delete() (Server)

@Objective: Deletes an existing identity.
local bool: result, table: arguments = cModule.delete(
  ~: identifier,
  ~: ...arguments
)

━ cModule.setData() (Server)

@Objective: Sets identity datas of a valid identity.
local bool: result, table: arguments = cModule.setData(
  ~: identifier,
  table: {
    --Columns to be updated w/ their respective values
    {string: columnName, ~: columnValue},
    ...
  },
  ~: ...arguments
)

━ cModule.getData() (Server)

@Objective: Retrieves identity datas of a valid identity.
local table: result, table: arguments = cModule.getData(
  ~: identifier,
  table: {
    --Columns whose values are to be retrieved
    string: columnName,
    ...
  },
  ~: ...arguments
)