buildQuery method
Build an sql query with the given query
, firstConditions
and conditions
.
If you don't give it, query
will be initialized with baseQuery
.
If you don't five it, firstConditions
will be initialized with baseConditions
.
Implementation
String buildQuery({
String? query,
String? firstConditions,
String? conditions,
}) {
query ??= _baseQuery;
firstConditions ??= _baseConditions;
if (firstConditions == null && conditions == null) {
return query;
}
String finalQuery = "$query WHERE ";
if (firstConditions != null) {
finalQuery += firstConditions;
if (conditions != null) {
finalQuery += " and ";
}
}
if (conditions != null) {
finalQuery += conditions;
}
return finalQuery;
}