group TenantDaoSql: EntitySqlDao;
tableName() ::= "tenants"
/** Don't add api_secret and api_salt in these fields, we shouldn't need to retrieve them */
tableFields(prefix) ::= <<
<prefix>external_key
, <prefix>api_key
, <prefix>created_date
, <prefix>created_by
, <prefix>updated_date
, <prefix>updated_by
>>
/** No account_record_id field */
accountRecordIdField(prefix) ::= ""
/** No tenant_record_id field */
tenantRecordIdField(prefix) ::= ""
create() ::= <<
INSERT INTO tenants (
id
, external_key
, api_key
, api_secret
, api_salt
, created_date
, created_by
, updated_date
, updated_by
) VALUES (
:id
, :externalKey
, :apiKey
, :apiSecret
, :apiSalt
, :createdDate
, :userName
, :updatedDate
, :userName
);
>>
getByApiKey() ::= <<
SELECT <tenantFields()>
FROM tenants
WHERE api_key = :apiKey;
>>
getSecrets() ::= <<
SELECT api_key, api_secret, api_salt
FROM tenants
WHERE id = :id;
>>