日期:2014-05-16 浏览次数:20427 次
import com.mongodb.* def m = new Mongo("localhost", 27017) def db = m.getDB("test") def things = db.getCollection("things") def bdo = new BasicDBObject() bdo.put("name", "Mongo") def subBdo = new BasicDBObject() subBdo.put("x", 1) subBdo.put("y", 2) bdo.put("info", subBdo) things.insert(bdo) def query = new BasicDBObject() query.put("name", "Mongo") def cur = things.find(query) while(cur.hasNext()){ println cur.next() }