Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BasicDBList to Collection MongoDB

Tags:

java

mongodb

This may seem like a dumb question but I don't know how to do this.

I have a document in a DBCollection that looks like this:

{ 
    "_id" : ObjectId("4ef4ee517e696a48037861c8"), 
    "income" : 2500, 
    "month" : "2011-12", 
    "expenses" : [    
                     {       
                         "id" : 1,       
                         "category" : "EMERGENCY",
                         "type" : "SAVING",      
                         "date" : "2011-12-23 10:25:30", 
                         "value" : 0.25" 
                     } ] 
}

I want to get all the elements of the inner array and put them into a Collection (Java Collection, e.g List<E>), but I can't seem to find anything on how to do it (and I've searched).

like image 851
Alvin Baena Avatar asked Jan 17 '23 23:01

Alvin Baena


1 Answers

It is already a java.util.List (BasicDBList implements java.util.List)

http://api.mongodb.org/java/current/com/mongodb/BasicDBList.html

like image 181
will Avatar answered Jan 25 '23 21:01

will