I am very new to mongodb and tryn to use it for developement.
I have a conceptual model of:
User={"uid":"", "services":"[
{
"serviceid":"sid",
"sub_dat":"somedate",
"exp_date":"somedate",
},
{
"serviceid":"sid",
"sub_dat":"somedate",
"exp_date":"somedate",
},
{
"serviceid":"sid",
"sub_dat":"somedate",
"exp_date":"somedate",
},
]",
"friends":"[
{
"friend_id":"",
"friendname":"name"
"friendshipyrs":"yrs",
},
{
"friend_id":"",
"friendname":"name"
"friendshipyrs":"yrs"
},
]", }
I wish to know the steps to follow in java with the raw driver, not morphia to, to: 1. create this object, such that i have the ability to: 2. fetch and append new services and friends to the service lists.
I can currently add to the top level and I tried using the BasicDBObject, DBList, and even the ObjectBUilder but could not figure out how to append or push into the fields to create the arrays/lists with the java driver as can be seen from the presentations on the 10gen site.
Also, want to be able to drill down to say.. friend info with a single query, so will it be advisable maintain above structure or create friends as a class and put the class objects in the list? I know of the dot operator, but i do not know how to access class fields through the java driver.
Will be very greatful for any help... Thank you