#include "..\script_component.hpp"

/*
 * Function: forge_client_db_fnc_loadFromProfile
 * Author: J. Schmidt
 * 
 * Description:
 * Loads data from profile namespace
 *
 * Arguments:
 * 0: _collectionName - Collection name <STRING>
 * 1: _key - Key to retrieve (Optional, get entire collection if empty) <STRING>
 * 2: _default - Default value if key not found <ANY>
 *
 * Return Value:
 * Retrieved data or default value
 */

params [
    ["_collectionName", "", [""]],
    ["_key", "", [""]],
    ["_default", nil]
];

private _database = call FUNC(verifyDB);
private _collection = _database call ["getCollection", [_collectionName]];

if (isNil "_collection") exitWith {
    _default
};

[_collectionName, _key, _default, profileNamespace] call FUNC(getFromCollection)