ramdb/docs/basic/fetch.md
Jacob Schmidt 5b9f3402b6
All checks were successful
Build / Build (push) Successful in 30s
docs: add comprehensive documentation and usage examples for ramdb
2025-03-22 16:31:59 -05:00

40 lines
2.1 KiB
Markdown

# ramdb_db_fnc_fetch
## Description
Handles data chunks received from the database extension when data is too large to be returned in a single callback. This function collects all chunks of data, reassembles them in the correct order, and then passes the complete data to the handler function.
## Syntax
```sqf
[_uniqueID, _function, _index, _total, _datachunk, _call, _netId] call ramdb_db_fnc_fetch
```
## Parameters
| Parameter | Type | Description |
|-------------|-----------|-------------------------------------------------------------|
| `_uniqueID` | String | Unique identifier for this data fetch operation |
| `_function` | String | Name of the function to call after data is assembled |
| `_index` | Number | Current chunk index (0-based) |
| `_total` | Number | Total number of chunks expected |
| `_datachunk`| String | The chunk of data being received |
| `_call` | Boolean | Whether to call the function directly (true) or spawn (false) |
| `_netId` | String | (Optional) NetID of the player to whom the data belongs |
## Return Value
None. When all chunks are received, the function will:
1. Assemble the complete data string
2. Parse it as a simple array
3. Call the specified handler function with the parsed data
## Examples
This function is typically not called directly but is triggered by the extension's callback mechanism when large datasets are retrieved.
## Notes
- The function stores received chunks in the global array `ramdb_db_fetch_array`
- Chunks are sorted by their index to ensure correct assembly regardless of arrival order
- After successful processing, the chunks for this uniqueID are removed from the array
- This function is essential for handling large datasets that exceed the callback buffer limit
## Related Functions
- `ramdb_db_fnc_handler`: Receives the assembled data and routes it to the appropriate function
- `ramdb_db_fnc_scheduler`: Manages the callback queue and triggers data fetching