ramdb/docs/core/addTask.md
Jacob Schmidt 136cc50336 docs: Correct internal links in core documentation
This commit corrects internal links within the core documentation files. The links were updated to point to the correct markdown files.

Key changes:

*   Updated links in `docs/core/processQueue.md`, `docs/core/addTask.md`, `docs/core/test.md`, `docs/core/scheduler.md`, `docs/core/handler.md`, `docs/core/printAddonName.md`, and `docs/core/init.md`.
2025-03-22 19:58:34 -05:00

68 lines
3.0 KiB
Markdown

---
title: ArmaRAMDb - Add Task
icon: mdi:file-text-outline
excerpt: Add task to queue.
---
# ramdb_db_fnc_addTask
## Description
Adds a task to the database operation queue. This function is used to schedule database operations that can be processed sequentially, providing a way to manage multiple database requests in an organized manner.
## Syntax
```sqf
[_taskType, _key, _keyField, _index, _value, _function, _call, _netId] call ramdb_db_fnc_addTask
```
## Parameters
| Parameter | Type | Description | Default |
|-------------|----------------------------------|----------------------------------------------------|---------|
| `_taskType` | String | Type of operation to perform (e.g., "hgetall") | "" |
| `_key` | String | Name of the stored key | "" |
| `_keyField` | String | Field name for hash operations | "" |
| `_index` | Number | Index for list operations | -1 |
| `_value` | Array, String, Number, or Boolean| Value to store (for set operations) | [] |
| `_function` | String | Name of function to call with the result | "" |
| `_call` | Boolean | Whether to call the function directly (true) or spawn (false) | false |
| `_netId` | String | NetID of the target to receive the result | "" |
## Return Value
None. The task is added to the queue and processed asynchronously.
## Examples
### Add a hash table retrieval task:
```sqf
["hgetall", "", "", -1, [], "ramdb_db_fnc_test"] call ramdb_db_fnc_addTask;
```
### Add a player-specific task that returns data to a specific client:
```sqf
["hgetallid", getPlayerUID player, "", -1, [], "ramdb_db_fnc_test", false, netId player] remoteExecCall ["ramdb_db_fnc_addTask", 2, false];
```
### Add a list operation task:
```sqf
["listadd", "playerMessages", "", -1, ["New message content"], ""] call ramdb_db_fnc_addTask;
```
## Notes
- Tasks are processed in the order they are added to the queue
- If the queue is not currently being processed, this function will start the processing
- The task type determines which database operation will be performed
- This function is particularly useful for scheduling multiple related operations
- All operations performed through the task queue are logged for debugging
## Related Functions
- `ramdb_db_fnc_processQueue`: Processes the pending tasks in the queue
- `ramdb_db_fnc_handler`: Handles the results of completed database operations
- `ramdb_db_fnc_scheduler`: Manages callback responses from the database
## Links
[Add Task](addTask.md) |
[Handler](handler.md) |
[Init](init.md) |
[Print Addon Name](printAddonName.md) |
[Process Queue](processQueue.md) |
[Scheduler](scheduler.md) |
[Test](test.md)