Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select Field #5

Open
Shelunagori opened this issue Sep 23, 2020 · 0 comments
Open

Select Field #5

Shelunagori opened this issue Sep 23, 2020 · 0 comments

Comments

@Shelunagori
Copy link

Shelunagori commented Sep 23, 2020

### Suggestion

Using this library I was not able to get a single field from the MongoDB collection.
I tried to execute a select query ( $this->mongo_db->select(array('foo', 'bar'))->get('foobar'); ). But it returns all the data of the document.
For fixing this issue I went through the library I found an issue in the get method. In the get method, there is $options variable in that array we are passing 'projection'. we just need to remove [] of 'projection'.

or you can replace below mention line in the library.

Current Code ( Mongo_db.php -> get function line no 776 )
$options = ['limit'=>(int) $this->limit, 'skip'=>(int) $this->offset, 'sort'=>$this->sorts, 'batchSize'=>(int)$this->limit, 'cursorType'=>2, ['projection'=>$this->selects]];

Replace to

$options = ['limit'=>(int) $this->limit, 'skip'=>(int) $this->offset, 'sort'=>$this->sorts, 'batchSize'=>(int)$this->limit, 'cursorType'=>2, 'projection'=>$this->selects];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant