Skip to content

Empty result set #3324

@bjaysheel

Description

@bjaysheel
  • Laravel-mongodb Version: 5.2
  • PHP Version: 8.3
  • Database Driver & Version: mongodb 8.0.4

Description:

Steps to reproduce

  1. Created a model
  2. Created a collection using mongo compass
  3. use php artisan tinker from laravel project root
  4. database query return null

Expected behaviour

Return documents from mongo collection

Actual behaviour

Return null or empty array

I have followed the instruction listed here my dsn is mongodb://127.0.0.1:27017 (I have even tried localhost instead of ip) In either case when using php artisan tinker to test the connection the result set is always empty. There are not errors reported so I assume connection is made to mongdb on localhost but it can't return any data from the collection. My model is

<?php

namespace App\Models;

use App\Helpers\SearchFormQueryBuilder;
use ElasticScoutDriverPlus\Builders\SearchRequestBuilder;
use Laravel\Scout\Searchable;
use ElasticScoutDriverPlus\CustomSearch;
use ElasticScoutDriverPlus\QueryDsl;
use MongoDB\Laravel\Eloquent\Model;
//use Laravel\Scout\Searchable;


class RVDB extends Model
{

    use Searchable;

    protected $connection = 'mongodb';
    protected $collection = 'annotation';
    protected $primaryKey = 'accession';

    protected $keyType = 'string';
}

and php tinker code is

> php artisan tinker
Psy Shell v0.12.7 (PHP 8.3.15 — cli) by Justin Hileman
> $r = new RVDB;
[!] Aliasing 'RVDB' to 'App\Models\RVDB' for this Tinker session.
= App\Models\RVDB {#5449}

> $r = new App\Models\RVDB;
= App\Models\RVDB {#5447}

> $r::first();
= null

> $r;
= App\Models\RVDB {#5447}

> exit

   INFO  Goodbye.

Not sure what I am missing.

Thank you
Jaysheel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions