当前位置: 首页>>代码示例>>Java>>正文


Java BasicDBObject.put方法代码示例

本文整理汇总了Java中com.mongodb.BasicDBObject.put方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDBObject.put方法的具体用法?Java BasicDBObject.put怎么用?Java BasicDBObject.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mongodb.BasicDBObject的用法示例。


在下文中一共展示了BasicDBObject.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildFilters

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
private void buildFilters(BasicDBObject pushdownFilters,
    Map<String, List<BasicDBObject>> mergedFilters) {
  for (Entry<String, List<BasicDBObject>> entry : mergedFilters.entrySet()) {
    List<BasicDBObject> list = entry.getValue();
    if (list.size() == 1) {
      this.filters.putAll(list.get(0).toMap());
    } else {
      BasicDBObject andQueryFilter = new BasicDBObject();
      andQueryFilter.put("$and", list);
      this.filters.putAll(andQueryFilter.toMap());
    }
  }
  if (pushdownFilters != null && !pushdownFilters.toMap().isEmpty()) {
    if (!mergedFilters.isEmpty()) {
      this.filters = MongoUtils.andFilterAtIndex(this.filters,
          pushdownFilters);
    } else {
      this.filters = pushdownFilters;
    }
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:MongoRecordReader.java

示例2: updateUserChangeNameAndSurnametoName

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
/**
 * update 6: {@link UserDocument} has changed; 'name' and 'surname' will be concat to 'name'.
 * for each every user document get 'name' and 'surname', concat them, update 'name', remove field surname and update document.
 *
 * @since V7
 */
@ChangeSet(order = "008", id = "updateUserChangeNameAndSurnameToName", author = "admin")
public void updateUserChangeNameAndSurnametoName(final MongoTemplate template) {
  final DBCollection userCollection = template.getCollection("user");

  final Iterator<DBObject> cursor = userCollection.find();
  while (cursor.hasNext()) {
    final DBObject current = cursor.next();

    final Object nameObj = current.get("name");
    final Object surnameObj = current.get("surname");
    final String updateName = (nameObj != null ? nameObj.toString() : "") + " " + (surnameObj != null ? surnameObj.toString() : "");

    final BasicDBObject updateQuery = new BasicDBObject();
    updateQuery.append("$set", new BasicDBObject("name", updateName));
    updateQuery.append("$unset", new BasicDBObject("surname", ""));

    final BasicDBObject searchQuery = new BasicDBObject();
    searchQuery.put("_id", current.get("_id"));

    userCollection.update(searchQuery, updateQuery);
  }
}
 
开发者ID:nkolytschew,项目名称:mongobee_migration_example,代码行数:29,代码来源:DatabaseChangeLog.java

示例3: mongoSerialise

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Override
public BasicDBObject mongoSerialise() {
    BasicDBObject dbObject = new BasicDBObject();

    dbObject.put("i", getObjectId());
    dbObject.put("t", ID);
    dbObject.put("x", getX());
    dbObject.put("y", getY());
    dbObject.put("direction", getDirection().ordinal());
    dbObject.put("heldItem", heldItem);
    dbObject.put("hp", hp);
    dbObject.put("action", lastAction.ordinal());
    dbObject.put("holo", hologram);
    dbObject.put("holoStr", hologramString);
    dbObject.put("holoMode", lastHologramMode.ordinal());
    dbObject.put("holoC", hologramColor);
    dbObject.put("energy", energy);

    if (parent != null) {
        dbObject.put("parent", parent.getUsername()); //Only used client-side for now
    }

    return dbObject;
}
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:25,代码来源:Cubot.java

示例4: clear

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void clear() throws IOException {
	/* build up the query, looking for all sessions with this app context property */
	BasicDBObject sessionQuery = new BasicDBObject();
	sessionQuery.put(appContextProperty, this.getName());

	/* remove all sessions for this context */
	try {
		this.collection.remove(sessionQuery);
		getLog().debug("removed sessions (query: " + sessionQuery + ")");
	} catch (MongoException e) {
		/* for some reason we couldn't save the data */
		getLog().error("Unable to remove sessions for [" + this.getName() + "] from MongoDB", e);
		throw e;
	}
}
 
开发者ID:appNG,项目名称:appng-tomcat-session,代码行数:19,代码来源:MongoStore.java

示例5: find

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Override
public List<Document> find(String collection, String signature) {
	List<Document> res = new ArrayList<Document>();
	try {
		MongoDatabase db = mongoClient.getDatabase(databaseName);
		MongoCollection<Document> coll = db.getCollection(collection);
		BasicDBObject searchQuery = new BasicDBObject();
		searchQuery.put("signature", signature);
		Iterable<Document> docs = coll.find(searchQuery);
		for (Document doc : docs) {
			res.add(doc);
		}
	} catch (Exception e) {
		LOG.error(e);
	}
	return res;
}
 
开发者ID:sap-nocops,项目名称:Jerkoff,代码行数:18,代码来源:MongoDBDaoImpl.java

示例6: InsertData

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
private int InsertData(SQLInsertStatement state) {
	if (state.getValues().getValues().size() ==0 ){
		throw new RuntimeException("number of  columns error");
	}		
	if (state.getValues().getValues().size() != state.getColumns().size()){
		throw new RuntimeException("number of values and columns have to match");
	}
	SQLTableSource table=state.getTableSource();
	BasicDBObject o = new BasicDBObject();
	int i=0;
	for(SQLExpr col : state.getColumns()) {
		o.put(getFieldName2(col), getExpValue(state.getValues().getValues().get(i)));
		i++;
	}		
	DBCollection coll =this._db.getCollection(table.toString());
	coll.insert(new DBObject[] { o });
	return 1;
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:19,代码来源:MongoSQLParser.java

示例7: UpData

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
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;		
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:17,代码来源:MongoSQLParser.java

示例8: andFilterAtIndex

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
public static BasicDBObject andFilterAtIndex(BasicDBObject leftFilter,
    BasicDBObject rightFilter) {
  BasicDBObject andQueryFilter = new BasicDBObject();
  List<BasicDBObject> filters = new ArrayList<BasicDBObject>();
  filters.add(leftFilter);
  filters.add(rightFilter);
  andQueryFilter.put("$and", filters);
  return andQueryFilter;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:MongoUtils.java

示例9: mongoSerialise

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Override
public BasicDBObject mongoSerialise() {

    BasicDBObject dbObject = new BasicDBObject();

    dbObject.put("hwid", (int) HWID);
    dbObject.put("cubot", cubot.getObjectId());

    if (floppyDisk != null) {
        dbObject.put("floppy", floppyDisk.mongoSerialise());
    }

    return dbObject;
}
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:15,代码来源:CubotFloppyDrive.java

示例10: convert

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Override
protected DBObject convert(MongoSession session) {

	BasicDBObject basicDBObject = new BasicDBObject();
	
	basicDBObject.put(ID, session.getId());
	basicDBObject.put(CREATION_TIME, session.getCreationTime());
	basicDBObject.put(LAST_ACCESSED_TIME, session.getLastAccessedTime());
	basicDBObject.put(MAX_INTERVAL, session.getMaxInactiveInterval());
	basicDBObject.put(PRINCIPAL_FIELD_NAME, extractPrincipal(session));
	basicDBObject.put(EXPIRE_AT_FIELD_NAME, session.getExpireAt());
	basicDBObject.put(ATTRIBUTES, serializeAttributes(session));

	return basicDBObject;
}
 
开发者ID:spring-projects,项目名称:spring-session-data-mongodb,代码行数:16,代码来源:JdkMongoSessionConverter.java

示例11: mongoSerialise

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Override
public BasicDBObject mongoSerialise() {
    BasicDBObject dbObject = new BasicDBObject();

    dbObject.put("i", getObjectId());
    dbObject.put("x", getX());
    dbObject.put("y", getY());
    dbObject.put("t", ID);

    return dbObject;
}
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:12,代码来源:RadioTower.java

示例12: mongoSerialise

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Override
public BasicDBObject mongoSerialise() {
    BasicDBObject dbObject = new BasicDBObject();

    dbObject.put("i", getObjectId());
    dbObject.put("x", getX());
    dbObject.put("y", getY());
    dbObject.put("direction", getDirection().ordinal());
    dbObject.put("hp", getHp());
    //  dbObject.put("energy", energy);
    dbObject.put("action", getAction().ordinal());
    dbObject.put("t", ID);

    return dbObject;
}
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:16,代码来源:HarvesterNPC.java

示例13: mongoSerialise

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
@Override
public BasicDBObject mongoSerialise() {

    BasicDBObject dbObject = new BasicDBObject();

    dbObject.put("t", ID);
    dbObject.put("i", getObjectId());
    dbObject.put("x", getX());
    dbObject.put("y", getY());
    dbObject.put("b", biomassCount);

    return dbObject;

}
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:15,代码来源:BiomassBlob.java

示例14: findByName

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
private FindIterable<Document> findByName(String collectionName, String userName) {
    MongoCollection<Document> collection = mongoDatabase.getCollection(collectionName);
    BasicDBObject searchQuery = new BasicDBObject();
    searchQuery.put("name", userName);
    return collection.find(searchQuery);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:7,代码来源:MongoMain.java

示例15: parserWhere

import com.mongodb.BasicDBObject; //导入方法依赖的package包/类
private void parserWhere(SQLExpr aexpr,BasicDBObject o){   
     if(aexpr instanceof SQLBinaryOpExpr){
	   SQLBinaryOpExpr expr=(SQLBinaryOpExpr)aexpr;  
	   SQLExpr exprL=expr.getLeft();
	   if (!(exprL instanceof SQLBinaryOpExpr))
	   {
		   //opSQLExpr((SQLBinaryOpExpr)aexpr,o);			   
		  if (expr.getOperator().getName().equals("=")) {  
	        o.put(exprL.toString(), getExpValue(expr.getRight()));
		  }
		  else {
			  String op="";
			  if (expr.getOperator().getName().equals("<")) {
				  op = "$lt";
			  }
			  if (expr.getOperator().getName().equals("<=")) {
				  op = "$lte";
			  }
			  if (expr.getOperator().getName().equals(">")) {
				  op = "$gt";
			  }
			  if (expr.getOperator().getName().equals(">=")) {
				  op = "$gte";
			  }
			  
			  if (expr.getOperator().getName().equals("!=")) {
				  op = "$ne";
			  }
			  if (expr.getOperator().getName().equals("<>")) {
				  op = "$ne";
			  }

			  parserDBObject(o,exprL.toString(),op, getExpValue(expr.getRight()));
		  }
		  
	   }
	   else {
		 if (expr.getOperator().getName().equals("AND")) {  
		   parserWhere(exprL,o); 
		   parserWhere(expr.getRight(),o);
		 }
		 else if (expr.getOperator().getName().equals("OR")) {  
			orWhere(exprL,expr.getRight(),o); 				
		 }
		 else {
			 throw new RuntimeException("Can't identify the operation of  of where"); 
		 }
	   }
   }
  
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:52,代码来源:MongoSQLParser.java


注:本文中的com.mongodb.BasicDBObject.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。