group TagDefinitionDao;

fields(prefix) ::= <<
    <prefix>id,
    <prefix>name,
    <prefix>description,
    <prefix>created_by,
    <prefix>created_date ,
    <prefix>updated_by,
    <prefix>updated_date
>>

get() ::= <<
  SELECT <fields()>
  FROM tag_definitions;
>>

create() ::= <<
  INSERT INTO tag_definitions(<fields()>)
  VALUES(:id, :name, :description, :userName, :createdDate, :userName, :updatedDate);
>>

load() ::= <<
  SELECT <fields()>
  FROM tag_definitions
  WHERE id = :id;
>>


deleteTagDefinition() ::= <<
  DELETE FROM tag_definitions
  WHERE id = :id;
>>

tagDefinitionUsageCount() ::= <<
  SELECT COUNT(id)
  FROM tags
  WHERE tag_definition_id = :id
>>

getByName() ::= <<
  SELECT <fields()>
   FROM tag_definitions
  WHERE name = :name;
>>

getById() ::= <<
  SELECT <fields()>
  FROM tag_definitions
  WHERE id = :id;
>>

getByIds(tag_definition_ids) ::= <<
  SELECT <fields()>
  FROM tag_definitions
  WHERE id IN (<tag_definition_ids: {id | :id_<i0>}; separator="," >)
>>
;
