use of com.mongodb.BasicDBObject in project Mycat-Server by MyCATApache.
the class MongoSQLParser method parserWhere.
private DBObject parserWhere(SQLExpr expr) {
BasicDBObject o = new BasicDBObject();
parserWhere(expr, o);
return o;
}
use of com.mongodb.BasicDBObject in project Mycat-Server by MyCATApache.
the class MongoSQLParser method UpData.
private int UpData(SQLUpdateStatement state) {
SQLTableSource table = state.getTableSource();
DBCollection coll = this._db.getCollection(table.toString());
SQLExpr expr = state.getWhere();
DBObject query = parserWhere(expr);
BasicDBObject set = new BasicDBObject();
for (SQLUpdateSetItem col : state.getItems()) {
set.put(getFieldName2(col.getColumn()), getExpValue(col.getValue()));
}
DBObject mod = new BasicDBObject("$set", set);
coll.updateMulti(query, mod);
//System.out.println("changs count:"+coll.getStats().size());
return 1;
}
use of com.mongodb.BasicDBObject in project Mycat-Server by MyCATApache.
the class MongoSQLParser method parserDBObject.
private void parserDBObject(BasicDBObject ob, String akey, String aop, Object aval) {
boolean isok = false;
if (!(ob.keySet().isEmpty())) {
for (String field : ob.keySet()) {
if (akey.equals(field)) {
Object val = ob.get(field);
if (val instanceof BasicDBObject) {
((BasicDBObject) val).put(aop, aval);
ob.put(field, (BasicDBObject) val);
isok = true;
break;
} else if (val instanceof BasicDBList) {
// newobj.put(field, ((BasicDBList)val).copy());
}
}
}
}
if (isok == false) {
BasicDBObject xo = new BasicDBObject();
xo.put(aop, aval);
ob.put(akey, xo);
}
}
use of com.mongodb.BasicDBObject in project javaee7-samples by javaee-samples.
the class Person method toDBObject.
public BasicDBObject toDBObject() {
BasicDBObject doc = new BasicDBObject();
doc.put("name", name);
doc.put("age", age);
return doc;
}
use of com.mongodb.BasicDBObject in project mongomvcc by igd-geo.
the class Tree method addCommit.
/**
* Adds a commit to the tree
* @param commit the commit to add
*/
public void addCommit(Commit commit) {
DBObject o = new BasicDBObject();
o.put(MongoDBConstants.ID, commit.getCID());
o.put(MongoDBConstants.TIMESTAMP, commit.getTimestamp());
o.put(PARENT_CID, commit.getParentCID());
o.put(ROOT_CID, commit.getRootCID());
DBObject objs = new BasicDBObject();
for (Map.Entry<String, IdMap> e : commit.getObjects().entrySet()) {
DBObject co = new BasicDBObject();
IdMapIterator it = e.getValue().iterator();
while (it.hasNext()) {
it.advance();
co.put(String.valueOf(it.key()), it.value());
}
objs.put(e.getKey(), co);
}
o.put(OBJECTS, objs);
_commits.insert(o);
}
Aggregations