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
expression.ts
[mov] server
Christian Fraß
commited
faf7e12
at 2021-03-08 23:05:42
expression.ts
Blame
History
Raw
namespace repositories { /** */ export var expression : helpers.repository_sqltable & {identify : (language_id : int, value : string)=>Promise<int>;} = { "setup": function () { return helpers.database.query_do_named("expression.setup"); }, "teardown": function () { throw (new Error("not implemented")); }, "create": function (row) { return helpers.database.query_put_free ( "INSERT INTO expressions(language_id, value) VALUES (:language_id, :value);", { "language_id": row["language_id"], "value": row["value"], } ); }, "update": function (concept_expression_id, row) { return helpers.database.query_do_free ( "UPDATE expressions SET language_id = :language_id, value = :value WHERE (id = :id)", { "id": concept_expression_id, "language_id": row["language_id"], "value": row["value"], } ); }, "delete": function (concept_expression_id) { return helpers.database.query_do_free ( "DELETE FROM expressions WHERE (id = :id)", { "id": concept_expression_id, } ); }, "read": async function (concept_expression_id) { return ( helpers.database.query_get_free ( "SELECT language_id,value FROM expressions WHERE (id = :id)", { "id": concept_expression_id, } ) .then ( (rows) => ( (rows.length === 1) ? Promise.resolve<type_row>(rows[0]) : Promise.reject<type_row>(new Error("not found")) ) ) ); }, "purge": async function (column, value) { return helpers.database.query_do_free ( "DELETE FROM expressions WHERE (" + column + " = :value)", { "value": value, } ); }, "take": async function (column, value) { return await helpers.database.query_get_free ( "SELECT language_id,value FROM expressions WHERE (" + column + " = :value)", { "value": value, } ); }, "identify": function (language_id : int, value : string) : Promise<int> { return ( helpers.database.query_get_free ( "SELECT id FROM expressions WHERE (language_id = :language_id) AND (value = :value);", { "language_id": language_id, "value": value, } ) .then ( (rows) => ( (rows.length === 1) ? Promise.resolve<int>(rows[0]["id"]) : Promise.reject<int>() ) ) ); }, }; }