Mongo newb here with a question. I'm using the java driver and noted
(please correct if I'm wrong) that DBObject is just a Map that also
has the following:
markAsPartialObject
isPartialObject
Now, I'm aware that the Map is really a document that could be a tree
of embedded objects, which is great. My question is, are the above two
methods absolutely necessary, or could there be another (dumbed) class
that could be used as well? The reason I'm asking is because it would
simplify things for me if Mongo could just store maps. Currently I
have code (which is working but if something doesn't look right please
let me know) that converts a Map to a DBObject:
Map dbo = ...
DBObject queryObject = new BasicDBObject();
queryObject.putAll(dbo);
DBCollection collection = db.getCollection(collectionName);
DBObject dbObject = new BasicDBObject();
dbObject.putAll(dbo);
collection.insert(dbObject);
dbo.clear();
dbo.putAll(dbObject.toMap());
return dbo;
The front end I'm (GWT) would easily handle passing around Maps, but
if mongo could store maps too, I wouldn't need any translation code at
all...
Thanks,
Mark