namespace repositories { /** */ export var concept_translations : helpers.repository_sqltable = { "setup": function () { return helpers.database.query_do_named("concept.setup-translations"); }, "teardown": function () { throw (new Error("not implemented")); }, "create": function (row) { return helpers.database.query_put_free ( "INSERT INTO concept_translations(concept_id, language_id, value) VALUES (:concept_id, :language_id, :value);", { "concept_id": row["concept_id"], "language_id": row["language_id"], "value": row["value"], } ); }, "update": function (concept_translation_id, row) { return helpers.database.query_do_free ( "UPDATE concept_translations SET concept_id = :concept_id, language_id = :language_id, value = :value WHERE (id = :id)", { "id": concept_translation_id, "concept_id": row["concept_id"], "language_id": row["language_id"], "value": row["value"], } ); }, "delete": function (concept_translation_id) { return helpers.database.query_do_free ( "DELETE FROM concept_translations WHERE (id = :id)", { "id": concept_translation_id, } ); }, "read": async function (concept_translation_id) { return ( helpers.database.query_get_free ( "SELECT concept_id,language_id,value FROM concept_translations WHERE (id = :id)", { "id": concept_translation_id, } ) .then ( (rows) => ( (rows.length === 1) ? Promise.resolve(rows[0]) : Promise.reject(new Error("not found")) ) ) ); }, "purge": async function (column, value) { return helpers.database.query_do_free ( "DELETE FROM concept_translations WHERE (" + column + " = :value)", { "value": value, } ); }, "take": async function (column, value) { return await helpers.database.query_get_free ( "SELECT concept_id,language_id,value FROM concept_translations WHERE (" + column + " = :value)", { "value": value, } ); }, }; }