formatting and typos

This commit is contained in:
DokaDoka committed 2022-12-11 15:00:43 +11:00
1 parent 75698216e0
commit 724c7e356d
99 files changed
+515 -305

No files matched your search

+3 -3
View File
@@ -24,7 +24,7 @@ If you are using VSCode with [sumneko Lua](https://marketplace.visualstudio.com/
Use your favourite package manager to install our [node package](https://www.npmjs.com/package/@overextended/oxmysql).
```yaml
```bash
# With pnpm
pnpm add @overextended/oxmysql
@@ -43,7 +43,7 @@ import { oxmysql as MySQL } from '@overextended/oxmysql';
## Placeholders
Safely format queries by using placeholders in the query, and sending arguments in an array or object.
Safely format queries by using placeholders in the query, and sending arguments in an array or object.
Named placeholders are not recommended, and unsupported when using MySQL.prepare.
```lua
@@ -59,5 +59,5 @@ When uncertain if a row should be inserted into the database, or an existing row
MySQL.prepare('INSERT INTO ox_inventory (owner, name, data) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data)', { owner, dbId, inventory })
```
This is preferred over checking the existence of a row, then inserting or updating depending on the result.
This is preferred over checking the existence of a row, then inserting or updating depending on the result.
Furthermore, unlike using 'REPLACE INTO', the row is not deleted and re-inserted.
+4
View File
@@ -5,6 +5,7 @@ Inserts a new entry into the database and returns the insert id for the row, if
## Lua
### Callback
```lua
-- alias: exports.oxmysql:insert
-- alias: MySQL.Async.insert
@@ -15,6 +16,7 @@ end)
```
### Promise
```lua
-- alias: exports.oxmysql:insert_async
-- alias: MySQL.Sync.insert
@@ -26,6 +28,7 @@ print(id)
## JavaScript
### Callback
```js
// alias: exports.oxmysql.insert
@@ -35,6 +38,7 @@ MySQL.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?,
```
### Promise
```js
// alias: exports.oxmysql.insert_async
+7 -3
View File
@@ -1,17 +1,18 @@
# Prepare
The only function that provides true [prepared statements](https://github.com/sidorares/node-mysql2#using-prepared-statements), granting native protection and query planning by MySQL.
Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.
The only function that provides true [prepared statements](https://github.com/sidorares/node-mysql2#using-prepared-statements), granting native protection and query planning by MySQL.
Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.
- Date will not return the datestring commonly used in FiveM
- TINYINT 1 and BIT will not return a boolean
- You can only use `?` value placeholders, `??` column placeholders and named placeholders will throw an error
- You can only use `?` value placeholders, `??` column placeholders and named placeholders will throw an error
When using SELECT, the return value will match `query, single, or scalar` depending on the number of columns and rows selected.
## Lua
### Callback
```lua
-- alias: exports.oxmysql:prepare
-- alias: MySQL.Async.prepare
@@ -24,6 +25,7 @@ end)
```
### Promise
```lua
-- alias: exports.oxmysql:prepare_async
-- alias: MySQL.Sync.prepare
@@ -37,6 +39,7 @@ end
## JavaScript
### Callback
```js
// alias: exports.oxmysql.prepare
@@ -48,6 +51,7 @@ MySQL.prepare('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (r
```
### Promise
```js
// alias: exports.oxmysql.prepare_async
+8 -1
View File
@@ -1,10 +1,12 @@
# Query
Generic function that can be utilised for any query.
Generic function that can be utilised for any query.
When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc.
## Lua
### Callback
```lua
-- alias: exports.oxmysql:query
-- alias: MySQL.Async.query
@@ -18,7 +20,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, func
end
end)
```
### Promise
```lua
-- alias: exports.oxmysql:query_async
-- alias: MySQL.Sync.query
@@ -35,6 +39,7 @@ end
## JavaScript
### Callback
```js
// alias: exports.oxmysql.query
@@ -46,7 +51,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (res
}
})
```
### Promise
```js
// alias: exports.oxmysql.query_async
+5
View File
@@ -1,9 +1,11 @@
# Scalar
Returns the first column for a single row.
## Lua
### Callback
```lua
-- alias: exports.oxmysql:scalar
-- alias: MySQL.Async.fetchScalar
@@ -14,6 +16,7 @@ end)
```
### Promise
```lua
-- alias: exports.oxmysql:scalar_async
-- alias: MySQL.Sync.fetchScalar
@@ -25,6 +28,7 @@ print(firstname)
## JavaScript
### Callback
```js
// alias: exports.oxmysql.scalar
@@ -34,6 +38,7 @@ MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifi
```
### Promise
```js
// alias: exports.oxmysql.scalar_async
+5
View File
@@ -1,9 +1,11 @@
# Single
Returns the columns for a single row.
## Lua
### Callback
```lua
-- alias: exports.oxmysql:single
-- alias: MySQL.Async.fetchSingle
@@ -16,6 +18,7 @@ end)
```
### Promise
```lua
-- alias: exports.oxmysql:single_async
-- alias: MySQL.Sync.fetchSingle
@@ -29,6 +32,7 @@ end
## JavaScript
### Callback
```js
// alias: exports.oxmysql.single
@@ -40,6 +44,7 @@ MySQL.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier],(row
```
### Promise
```js
// alias: exports.oxmysql.single_async
+1 -1
View File
@@ -67,7 +67,7 @@ console.log(success);
## Shared Format
When using the `Shared` format you must pass two parameters to the oxmysql export. The `queries` and the `parameters` those queries will use.
When using the `Shared` format you must pass two parameters to the oxmysql export. The `queries` and the `parameters` those queries will use.
This is useful if your queries use the same SQL variables.
### Lua
+5
View File
@@ -1,9 +1,11 @@
# Update
Returns the number of affected rows by the query.
## Lua
### Callback
```lua
-- alias: exports.oxmysql:update
-- alias: MySQL.Async.execute
@@ -16,6 +18,7 @@ end)
```
### Promise
```lua
-- alias: exports.oxmysql:update_async
-- alias: MySQL.Sync.execute
@@ -29,6 +32,7 @@ end
## JavaScript
### Callback
```js
// alias: exports.oxmysql.update
@@ -40,6 +44,7 @@ MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, p
```
### Promise
```js
// alias: exports.oxmysql.update_async