We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to store nested object in the mongo db documents

Hello,

I have the below Json, How do I store the "geo" object ?

page =  {    
                'name' => 'one',
                'intro' => 'sample' ,
                'geo' =>  {  '_id' => { 
                                        '$id' => '2332azcvxc', 
                                        'name' => 'india' 
                                    }
                                }
            }

Why the below lines are not working ?

$page = new Page();
$geo = new Geo();
$page->geo = $geo; 
$page->save();

Any suggestion please ?

Thanks, Raja K



145.0k
Accepted
answer
$page = new $page();

What is this ?



13.2k

Sorry typo, it's

       $page = new Page();

Thanks,' Raja K

Hello

You can store nested object in the mongo db documents just visit example https://zappysys.com/blog/ssis-loading-data-into-mongodb-upsert-update-delete-insert/

I hope it will help, i also have the same problem it solved with this example