You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 functionline no 776 )
$options = ['limit'=>(int) $this->limit, 'skip'=>(int) $this->offset, 'sort'=>$this->sorts, 'batchSize'=>(int)$this->limit, 'cursorType'=>2, ['projection'=>$this->selects]];
### 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];
The text was updated successfully, but these errors were encountered: