Skip to content
Projetos

Sobre

MySQL resource for FXServer.

Dados e análise

Como estes números são medidos

O que você pode fazer

  • Support for mysql-async and ghmattimysql syntax.
  • Promises / async query handling allowing for non-blocking and awaitable responses.
  • Improved performance and stability compared to other options.
  • Support for named and unnamed placeholders, improving performance and security.

Crescimento medido de estrelas

em 24 h
0
em 7 dias
-1
em 15 dias
0
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

README.md

Original

oxmysql

A FiveM resource to communicate with a MySQL database using node-mysql2.


Refer to CONTRIBUTING.md for contribution guidelines and to see our Contributor License Agreement.
Refer to NOTICE.md for additional information and legal notices.

🔗 Links

  • 💾 Download
    • Download the latest release directly.
  • 📚 Documentation
    • For installation, setup, and everything else.
  • 📦 npm
    • Use our npm package for enhanced functionality and TypeScript support.

✨ Features

  • Support for mysql-async and ghmattimysql syntax.
  • Promises / async query handling allowing for non-blocking and awaitable responses.
  • Improved performance and stability compared to other options.
  • Support for named and unnamed placeholders, improving performance and security.
  • Support for URI connection strings and semicolon separated values.
  • Improved parameter checking and error handling.

Lua query builder

Load the imports you need in your resource's fxmanifest.lua:

server_scripts {
    '@oxmysql/lib/MySQL.lua',
    '@oxmysql/lib/Builder.lua',
    'server.lua',
}

Builder provides SELECT, INSERT, and UPDATE queries and predicate operators. MySQL provides the existing raw SQL functions. The imports work independently and can be loaded in either order.

local users = Builder.table('users')
    :select({ 'id', 'name' })
    :where(Builder.op.eq('active', true))
    :limit(10)
    :get()

local insertId = Builder.table('users'):insert({ name = 'Avery', active = true })

local affectedRows = Builder.table('users')
    :where(Builder.op.eq('id', insertId))
    :update({ active = false })

local count = MySQL.scalar.await('SELECT COUNT(*) FROM users')

insert(rowOrRows, callback?) accepts a non-empty row map or a dense array of rows with identical column names. update(values, callback?) requires a where predicate; use :allowAll():update(values) to deliberately update every row. Without callbacks, both terminals await internally. Mutation values use the same scalar rules as predicates. Column map keys must be unqualified names. select() and limit() are unsupported on mutations; where() and allowAll() are unsupported on inserts.

Existing builder calls must change from MySQL.table / MySQL.op to Builder.table / Builder.op and load @oxmysql/lib/Builder.lua.

For coding agents, the oxmysql query builder skill covers imports, supported queries, execution behavior, and migration from the earlier MySQL builder namespace.

🧾 Logging

We have included a module for submitting error logs to Fivemanage, a cloud management service tailored for game servers. Additional logging options and support for other services will be available in the future.

Lua Language Server

  • Install Lua Language Server to ease development with annotations, type checking, diagnostics, and more.
  • See ox_types for our Lua type definitions.

Explore projetos relacionados

Carregando…