self:delete

Server

Appends a row deletion to the query


Syntax

local query = self:delete()

This function only prepares the query and does not execute it. Chain db_query:execute at the end to commit the query to the core.database.

  • Chaining — compatible with :where to target specific rows for deletion.
  • Multiple deletions — chain multiple :delete calls to append additional row deletions.
  • Multiple conditions — chain multiple :where calls to apply additional filters to the deletion.
  • Without conditions — omitting :where will delete all rows in the table.

Parameters

No parameters are accepted by this function

Returns

TypeNameDescription
db_query | boolqueryQuery builder instance on successful execution, false otherwise

Examples

Delete a specific player record
local db = core.database.create("127.0.0.1", "root", "", "vital_sandbox")

util.thread.create(function(self)
    local ok, err = self:await(db:table("players")
        :delete()
        :where("name", "=", "aviril")
        :execute())

    if not ok then
        core.engine.print("error", err)
    end
end):resume()
Delete all rows in the 'players' table
local db = core.database.create("127.0.0.1", "root", "", "vital_sandbox")

util.thread.create(function(self)
    local ok, err = self:await(db:table("players")
        :delete()
        :execute())

    if not ok then
        core.engine.print("error", err)
    end
end):resume()

On this page