Java driver

34 views
Skip to first unread message

mongobee

unread,
Sep 11, 2012, 11:58:21 PM9/11/12
to mongod...@googlegroups.com
import com.mongo.BasicDBObject;
import com.mongodb.DBObject;
 
I think both BasicDBObject and DBObject classes are used to create handle for document object. What is the difference?
 

Rob Moore

unread,
Sep 12, 2012, 12:11:08 AM9/12/12
to mongod...@googlegroups.com

DBObject is the interface and BasicDBObject the implementation.

http://api.mongodb.org/java/2.9.1/com/mongodb/DBObject.html
http://api.mongodb.org/java/2.9.1/com/mongodb/BasicDBObject.html

In theory you could create a class that implemented the interface and then use it with the driver. 

Rob.

http://www.allanbank.com/mongodb-async-driver/

Wes Freeman

unread,
Sep 12, 2012, 12:11:27 AM9/12/12
to mongod...@googlegroups.com
I've often wondered why they broke that out. DBObject is an interface, where BasicDBObject implements the interface. Maybe they had intentions to create a different kind of DBObject that wasn't LinkedHashMap based.

Wes

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

mongobee

unread,
Sep 12, 2012, 1:08:50 AM9/12/12
to mongod...@googlegroups.com
thanks Rob and Wes.
 
Another basic question - is there any samples out there that explains how logic implemented in stored procedures (SQL based) are coded in mongodb?
what is equivalent of SQL views?

Rob Moore

unread,
Sep 12, 2012, 1:19:53 AM9/12/12
to mongod...@googlegroups.com

There are a number of ways to run "logic" on the MongoDB server:

JavaScript "$where" clauses:
    http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-JavascriptExpressionsand{{%24where}}
Map/Reduce:
    http://www.mongodb.org/display/DOCS/MapReduce
Aggregation Pipelines:
    http://docs.mongodb.org/manual/reference/method/db.collection.aggregate/

The Map/Reduce and $where has the ability to use functions defined on the server which is sort of like a stored procedure.
    http://www.mongodb.org/display/DOCS/Server-side+Code+Execution

The Aggregation "$project" operator is probably the closest thing to a SQL view:
    http://docs.mongodb.org/manual/reference/aggregation/project/

Hope this helps or at least gets you started...

Rob.

mongobee

unread,
Sep 12, 2012, 1:31:29 AM9/12/12
to mongod...@googlegroups.com
This is great. thanks Rob.
Reply all
Reply to author
Forward
0 new messages