backend/source/repositories/name_index.ts
2024-04-29 20:48:20 +02:00

74 lines
1.2 KiB
TypeScript

namespace _espe.repository.member
{
/**
*/
var _chest : (
null
|
lib_plankton.storage.type_chest<
Array<any>,
Record<string, any>,
lib_plankton.database.type_description_create_table,
lib_plankton.storage.type_sql_table_common_search_term,
Record<string, any>
>
) = null;
/**
*/
function get_chest(
) : lib_plankton.storage.type_chest<
Array<any>,
Record<string, any>,
lib_plankton.database.type_description_create_table,
lib_plankton.storage.type_sql_table_common_search_term,
Record<string, any>
>
{
if (_chest === null) {
_chest = lib_plankton.storage.sql_table_common_chest(
{
"database_implementation": _espe.helpers.database_implementation(),
"table_name": "name_indices",
"key_names": ["name_image"],
}
);
}
else {
// do nothing
}
return _chest;
}
/**
*/
export async function read(
name : string
) : Promise<int>
{
let row : Record<string, any>;
try {
row = await get_chest().read(name);
return row["index"];
}
catch (error) {
return 0;
}
}
/**
*/
export async function write(
name : string,
index : int
) : Promise<void>
{
return get_chest().write(name, index);
}
}