backend/source/repositories/auth_internal.ts
2024-09-19 13:34:07 +02:00

82 lines
1.4 KiB
TypeScript

namespace _zeitbild.repository.auth_internal
{
/**
*/
var _chest : (
null
|
lib_plankton.storage.type_chest<
Array<string>,
Record<string, any>,
lib_plankton.database.type_description_create_table,
lib_plankton.storage.sql_table_common.type_sql_table_common_search_term,
Record<string, any>
>
) = null;
/**
*/
function get_chest(
) : lib_plankton.storage.type_chest<
Array<string>,
Record<string, any>,
lib_plankton.database.type_description_create_table,
lib_plankton.storage.sql_table_common.type_sql_table_common_search_term,
Record<string, any>
>
{
if (_chest === null) {
_chest = lib_plankton.storage.sql_table_common.chest(
{
"database_implementation": _zeitbild.database.get_implementation(),
"table_name": "auth_internal",
"key_names": ["name"],
}
);
}
else {
// do nothing
}
return _chest;
}
/**
*/
export function read(
name : string
) : Promise<string>
{
return (
get_chest().read([name])
.then(
(row) => Promise.resolve<string>(row["password_image"])
)
);
}
/**
*/
export function write(
name : string,
password_image : string
) : Promise<boolean>
{
return get_chest().write([name], {"password_image": password_image});
}
/**
*/
export function delete_(
name : string
) : Promise<void>
{
return get_chest().delete([name]);
}
}