ramdb/docs/README.md

148 lines
4.8 KiB
Markdown

# ArmaRAMDb Documentation
This documentation provides details on all functions available in `ArmaRAMDb`. These functions allow you to interact with the in-memory database system for Arma 3.
## Function Categories
The functions are categorized by their purpose:
### Core Functions
- [init](core/init.md) - Initialize the database system
- [handler](core/handler.md) - Handle callbacks from the extension
- [processQueue](core/processQueue.md) - Process queued database operations
- [scheduler](core/scheduler.md) - Schedule database operations
- [addTask](core/addTask.md) - Add a task to the scheduler
- [printAddonName](core/printAddonName.md) - Print the addon name
- [test](core/test.md) - Test the database connection
### Basic Data Operations
- [get](basic/get.md) - Get a value from the database
- [set](basic/set.md) - Set a value in the database
- [delete](basic/delete.md) - Delete a value from the database
- [save](basic/save.md) - Save the database to disk
- [load](basic/load.md) - Load the database from disk
- [fetch](basic/fetch.md) - Fetch a value from the database
### Hash Operations
- [hashDelete](hash/hashDelete.md) - Delete a hash
- [hashDeleteId](hash/hashDeleteId.md) - Delete a hash for a specific ID
- [hashGet](hash/hashGet.md) - Get a field from a hash
- [hashGetAll](hash/hashGetAll.md) - Get all fields from a hash
- [hashGetAllId](hash/hashGetAllId.md) - Get all fields from a hash for a specific ID
- [hashGetId](hash/hashGetId.md) - Get a field from a hash for a specific ID
- [hashRemove](hash/hashRemove.md) - Remove a field from a hash
- [hashRemoveId](hash/hashRemoveId.md) - Remove a field from a hash for a specific ID
- [hashSet](hash/hashSet.md) - Set a field in a hash
- [hashSetBulk](hash/hashSetBulk.md) - Set multiple fields in a hash in one operation
- [hashSetId](hash/hashSetId.md) - Set a field in a hash for a specific ID
- [hashSetIdBulk](hash/hashSetIdBulk.md) - Set multiple fields in a hash for a specific ID in one operation
### List Operations
- [listAdd](list/listAdd.md) - Add an item to a list
- [listDelete](list/listDelete.md) - Delete a list
- [listGet](list/listGet.md) - Get items from a list
- [listLoad](list/listLoad.md) - Load a list from the database
- [listRemove](list/listRemove.md) - Remove an item from a list
- [listSet](list/listSet.md) - Set an item in a list
## Usage Examples
### Basic Usage
```sqf
// Initialize the database
[] call ramdb_db_fnc_init;
// Set a value
["myKey", [myValue]] call ramdb_db_fnc_set;
// Get a value
["myKey", "myFunction"] call ramdb_db_fnc_get;
// Delete a key
["myKey"] call ramdb_db_fnc_delete;
```
### Hash Operations
```sqf
// Set a hash field (context mode)
["myField", [myValue]] call ramdb_db_fnc_hashSet;
// Get a hash field (context mode)
["myField", "myFunction"] call ramdb_db_fnc_hashGet;
// Get all hash fields (context mode)
["myFunction"] call ramdb_db_fnc_hashGetAll;
// Set multiple hash fields (context mode)
[[
"loadout", [getUnitLoadout player],
"position", [getPosASL player],
"direction", [getDir player],
"stance", [stance player]
]] call ramdb_db_fnc_hashSetBulk;
// Remove a hash field (context mode)
["myField"] call ramdb_db_fnc_hashRemove;
// Delete a hash table (context mode)
[] call ramdb_db_fnc_hashDelete;
```
```sqf
// Set a hash field for specific ID
["myHash", "myField", [myValue]] call ramdb_db_fnc_hashSetId;
// Get a hash field for specific ID
["myHash", "myField", "myFunction"] call ramdb_db_fnc_hashGetId;
// Get all hash fields for specific ID
["myHash"] call ramdb_db_fnc_hashGetAllId;
// Set multiple hash fields for specific ID
[[
getPlayerUID player,
"loadout", [getUnitLoadout player],
"position", [getPosASL player],
"direction", [getDir player],
"stance", [stance player]
]] call ramdb_db_fnc_hashSetIdBulk;
// Remove a hash field for specific ID
["myHash", "myField"] call ramdb_db_fnc_hashRemoveId;
// Delete a hash table for specific ID
["myHash"] call ramdb_db_fnc_hashDeleteId;
```
### List Operations
```sqf
// Add an item to a list
["myList", ["myItem"]] call ramdb_db_fnc_listAdd;
// Set an item from a list
["myList", 0, [myNewValue]] call ramdb_db_fnc_listSet;
// Get an item from a list
["myList", 0, "myFunction"] call ramdb_db_fnc_listGet;
// Get items from a list
["myList", "myFunction"] call ramdb_db_fnc_listLoad;
// Remove an item from a list
["myList", 0] call ramdb_db_fnc_listRemove;
// Delete a list
["myList"] call ramdb_db_fnc_listDelete;
```
## Function Documentation Structure
Each function documentation includes:
- Function name and purpose
- Parameters
- Return value
- Examples
- Notes and warnings
## License
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, <br>PO Box 1866, Mountain View, CA 94042