SelectBloc constructor

SelectBloc({
  1. required Db database,
  2. String? query,
  3. String? table,
  4. int? offset,
  5. int? limit,
  6. String? where,
  7. String columns = "*",
  8. String? joinTable,
  9. String? joinOn,
  10. String? orderBy,
  11. bool reactive = false,
  12. bool verbose = false,
})

Create a select bloc with the specified options. The select bloc will fire a query on creation

Implementation

SelectBloc(
    {required this.database,
    this.query,
    this.table,
    this.offset,
    this.limit,
    this.where,
    this.columns = "*",
    this.joinTable,
    this.joinOn,
    this.orderBy,
    this.reactive = false,
    this.verbose = false})
    : assert(database != null),
      assert(database.isReady) {
  if ((query == null) && (table == null)) {
    throw ArgumentError("Please provide either a table or a query argument");
  }

  _getItems();
  if (reactive) {
    _changefeed = database.changefeed.listen((change) {
      if ((table != null && change.table == table) ||
          (query != null && change.query == query)) {
        _getItems();
      }
      if (verbose) {
        print("CHANGE IN THE DATABASE: $change");
      }
    });
  }
}