overextended/oxmysql
关于
MySQL resource for FXServer.
数据与分析可以做什么
- 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.
实测星标增长
- 24小时
- 0
- 7天
- -1
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文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.
探索相关项目
加载中…