git.schokokeks.org
Repositories
Help
Report an Issue
fs-words.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
9815a42
Branches
Tags
develop-client_server
master
typescript
fs-words.git
source
repositories
type.ts
[add] typescript logic
Christian Fraß
commited
9815a42
at 2021-03-03 00:27:18
type.ts
Blame
History
Raw
namespace repositories { export var type : helpers.repository_sqltable & {identify : (value : string)=>Promise<int>;} = { "setup": async function () { await helpers.database.query_put_named("type.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 types(value) VALUES (:value);", { "value": row["value"], } ); }, "update": function (type_id, row) { return helpers.database.query_do_free ( "UPDATE types SET value = :vaule WHERE (id = :id);", { "id": type_id, "value": row["value"], } ); }, "delete": function (type_id) { return helpers.database.query_do_free ( "DELETE FROM types WHERE (id = :id);", { "id": type_id, } ); }, "read": function (type_id) { return ( helpers.database.query_get_free ( "SELECT value FROM types WHERE (id = :id);", { "id": type_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 types WHERE (value = :value);", { "value": value, } ) .then ( (rows) => ( (rows.length === 1) ? Promise.resolve<int>(rows[0]["id"]) : Promise.reject<int>() ) ) ); }, }; }