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