Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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



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

What is this ?



3.9k

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