getQueryObjectsList<T> method

List<T> getQueryObjectsList<T>(
  1. QueryObjectBuilder<T> queryObj, {
  2. String? whereString,
})

Get a list of items defined by the queryObj.

Optionally a custom whereString piece can be passed in. It can start with the keyword where.

Implementation

List<T> getQueryObjectsList<T>(QueryObjectBuilder<T> queryObj,
    {String? whereString}) {
  String querySql = "${queryObj.querySql()}";
  if (whereString != null && whereString.isNotEmpty) {
    if (whereString.trim().toLowerCase().startsWith("where")) {
      querySql += whereString;
    } else {
      querySql += " where $whereString";
    }
  }

  List<T> items = [];
  var res = select(querySql);
  res.forEach((QueryResultRow row) {
    var obj = queryObj.fromRow(row);
    items.add(obj);
  });
  return items;
}