I am thinking that an event driven CustomEngine might not be a bad idea.
At the moment I have a bunch of data that is sitting in Elasticsearch (which represents a few million rows inside my MySQL db).
If I was able to have an event driven engine, then I could specify with a callback the variables I need to:
Search
Order
Filter/Limit
Then inside the CustomEngine, I could either return the data, or alternatively, provide another callback to retrieve the data that I want to show inside the Datatable.
I imagine using it similar to:
use \Chumper\Datatable\Datatable;
use \Chumper\Datatable\DatatableQuery;
class ComplexDatatableController {
public function getDatatable() {
$dt = new Datatable();
return $dt->custom(
function (DatatableQuery $filter) {
return $elasticsearch->find($filter->searchString)->getIndexID();
},
function (DatatableResults $results) {
return $mysql->findByID($results->getArray());
})
->showColumns('id', 'name', 'description')
->searchColumns('name', 'description')
->orderColumns('id','name', 'description')
->make();
}
}
The CustomEngine would have two parameters on the class, a filter, and a results processor. If the second parameter is left null, it is assumed that the filter will also return the results that will be used by the Datatables VersionResponse. Otherwise, it is assumed that the filter will just return IDs/other references that can be used to grab the results.
Where the DatatableQuery would have all the values of the query (implementing an interface similar to #333?)
class DatatableQuery
{
/** @var bool do we need to search on columns, or just order & filter? */
public $searchColumns = false;
/** @var bool are we using a plugin to search individual plugins */
public $searchIndividualColumns = true;
/** @var string The string we are searching for (note: for searchColumns) */
public $searchString = '';
/** @var array the columns that we are searching, the content that has been put in */
public $searchColumn = [];
/** @var bool the search is a regular expression */
public $searchRegex = true;
/** @var int the number of columns we are showing in the datatable */
public $numberOfColumns = 0;
/** @var array a list of all the columns we are showing */
public $columns = [];
/** @var array a list of the columns we are sorting by, with their direction */
/* [ [ 'id' => 'desc' ], [ 'name', 'asc' ] ] */
public $order = [];
/** @var int which result to start from */
public $start = 0;
/** @var int the limit of the result. */
public $limit = 0;
}
I am thinking that an event driven
CustomEngine
might not be a bad idea.At the moment I have a bunch of data that is sitting in Elasticsearch (which represents a few million rows inside my MySQL db).
If I was able to have an event driven engine, then I could specify with a callback the variables I need to:
Then inside the CustomEngine, I could either return the data, or alternatively, provide another callback to retrieve the data that I want to show inside the Datatable.
I imagine using it similar to:
The CustomEngine would have two parameters on the class, a filter, and a results processor. If the second parameter is left null, it is assumed that the filter will also return the results that will be used by the Datatables
VersionResponse
. Otherwise, it is assumed that the filter will just return IDs/other references that can be used to grab the results.Where the DatatableQuery would have all the values of the query (implementing an interface similar to #333?)