Commit bb776aa5 authored by fso's avatar fso

Add cursor support

parent 84cd2418
......@@ -3,6 +3,7 @@ declare(strict_types=1);
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\LazyCollection;
use Jenssegers\Mongodb\Collection;
use Jenssegers\Mongodb\Query\Builder;
use MongoDB\BSON\ObjectId;
......@@ -759,4 +760,24 @@ class QueryBuilderTest extends TestCase
$this->assertEquals('spork', $results[1]['name']);
$this->assertEquals('fork', $results[0]['name']);
}
public function testCursor()
{
$data = [
['name' => 'fork', 'tags' => ['sharp', 'pointy']],
['name' => 'spork', 'tags' => ['sharp', 'pointy', 'round', 'bowl']],
['name' => 'spoon', 'tags' => ['round', 'bowl']],
];
DB::collection('items')->insert($data);
$results = DB::collection('items')->orderBy('_id', 'asc')->cursor();
$this->assertInstanceOf(LazyCollection::class, $results);
$i = 0;
foreach ($results as $result) {
$this->assertEquals($data[$i]['name'], $result['name']);
$i++;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment