git.schokokeks.org
Repositories
Help
Report an Issue
fs-words.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
faf7e12
Branches
Tags
develop-client_server
master
typescript
fs-words.git
server
source
repositories
language.ts
[mov] server
Christian Fraß
commited
faf7e12
at 2021-03-08 23:05:42
language.ts
Blame
History
Raw
namespace repositories { export var language : helpers.repository_sqltable & {identify : (value : string)=>Promise<int>;} = { "setup": async function () { await helpers.database.query_put_named("language.setup"); return Promise.resolve<void>(undefined); }, "teardown": function () { return Promise.reject(new Error("not implemented")); }, "create": function (row) { return helpers.database.query_put_free ( "INSERT INTO languages(value) VALUES (:value);", { "value": row["value"], } ); }, "update": function (language_id, row) { return helpers.database.query_do_free ( "UPDATE languages SET value = :vaule WHERE (id = :id);", { "id": language_id, "value": row["value"], } ); }, "delete": function (language_id) { return helpers.database.query_do_free ( "DELETE FROM languages WHERE (id = :id);", { "id": language_id, } ); }, "read": function (language_id) { return ( helpers.database.query_get_free ( "SELECT value FROM languages WHERE (id = :id);", { "id": language_id, } ) .then ( (rows) => ( (rows.length === 1) ? Promise.resolve<type_row>(rows[0]) : Promise.reject<type_row>(new Error("not found")) ) ) ); }, "purge": function (column, value) { return Promise.reject(new Error("not implemented")); }, "take": function (column, value) { return Promise.reject(new Error("not implemented")); }, "identify": function (value : string) : Promise<int> { return ( helpers.database.query_get_free ( "SELECT id FROM languages WHERE (value = :value);", { "value": value, } ) .then ( (rows) => ( (rows.length === 1) ? Promise.resolve<int>(rows[0]["id"]) : Promise.reject<int>() ) ) ); }, }; }