implement index:get method

This commit is contained in:
ghost 2024-02-12 23:33:03 +02:00
parent 7da0ac4a5e
commit 3373b57d1e

View File

@ -131,6 +131,61 @@ class Manticore
); );
} }
public function get(
?string $search = '',
?array $filter = [],
?array $sort = ['id' => 'desc'],
?int $offset = 0,
?int $limit = 2
): array
{
$records = [];
$search = $this->_index->search(
$search
);
foreach ($filter as $key => $value)
{
$search->filter(
$key,
$value
);
}
foreach ($sort as $key => $value)
{
$search->sort(
$key,
$value
);
}
$search->offset(
$offset
);
$search->limit(
$limit
);
foreach ($search->get() as $record)
{
$records[$record->getId()] =
[
'time' => $record->get('time'),
'size' => $record->get('size'),
'block' => $record->get('block'),
'namespace' => $record->get('namespace'),
'transaction' => $record->get('transaction'),
'key' => $record->get('key'),
'value' => $record->get('value')
];
}
return $records;
}
public function drop(?bool $silent = false) public function drop(?bool $silent = false)
{ {
return $this->_index->drop( return $this->_index->drop(