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;
>>

deleteAllTagsForDefinition() ::= <<
  DELETE FROM tags
  WHERE tag_definition_name = :name;
>>

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

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

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


