I am trying to execute a simple program that can extract all the data stored in a MongoDB collection in tabular form. I am following the example programs provided on the koolreport website. They have clearly mentioned how to extract data from the nonobject column type. Which is working absolutely fine. But the program is not able to fetch the data from the inherited columns. It says "Fatal error: Uncaught Error: Object of class MongoDB\Model\BSONDocument could not be converted to the string".
I looked for solutions to this problem. I came across converting the MongoDB document into PHP so that data is presentable. But It kept showing the same error.
MongoDB collection (Employee) structure:
{
"name" : string,
"tech" : {
"name" : string
}
}
setup function:
{
$this->src('data')
->query(array (
"collection"=>"Employee",
"option"=>[
"projection"=>[
"name"=>1,
"tech.name"=>1
]
]
))
->pipe($this->dataStore('result'));
}
Error: Fatal error: Uncaught Error: Object of class MongoDB\Model\BSONDocument could not be converted to string in C:\xampp\htdocs\demo\vendor\koolreport\core\src\widgets\koolphp\Table.tpl.php:138 Stack trace: #0 C:\xampp\htdocs\demo\vendor\koolreport\core\src\core\Widget.php(736): include() #1 C:\xampp\htdocs\demo\vendor\koolreport\core\src\widgets\koolphp\Table.php(431): koolreport\core\Widget->template('Table', Array) #2 C:\xampp\htdocs\demo\vendor\koolreport\core\src\core\Widget.php(676): koolreport\widgets\koolphp\Table->onRender() #3 C:\xampp\htdocs\demo\vendor\koolreport\core\src\core\Widget.php(764): koolreport\core\Widget->render() #4 C:\xampp\htdocs\demo\demoReport\demoReport.view.php(10): koolreport\core\Widget::create(Array) #5 C:\xampp\htdocs\demo\vendor\koolreport\core\src\KoolReport.php(502): include('C:\xampp\htdocs...') #6 C:\xampp\htdocs\demo\demoReport\index.php(8): koolreport\KoolReport->render() #7 {main} thrown in ### C:\xampp\htdocs\demo\vendor\koolreport\core\src\widgets\koolphp\Table.tpl.php on line 138