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


Java DBCollection.remove方法代码示例

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


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

示例1: testFindOne

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public void testFindOne() throws UnknownHostException {
	MarcMongodbClient client = new MarcMongodbClient("localhost" , 27017, "sub_last_print");
	DBCollection collection = client.getCollection("marc");
	BasicDBObject doc = createTestObject();
	collection.insert(doc);
	assertEquals(1, collection.count());
	DBObject myDoc = collection.findOne();
	assertEquals("MongoDB", myDoc.get("name"));
	assertEquals("database", myDoc.get("type"));
	assertEquals(1, myDoc.get("count"));
	assertEquals(BasicDBObject.class, myDoc.get("info").getClass());
	assertEquals(new BasicDBObject("x", 203).append("y", 102), myDoc.get("info"));
	assertEquals(203, ((BasicDBObject)myDoc.get("info")).get("x"));
	assertEquals(Integer.class, ((BasicDBObject)myDoc.get("info")).get("x").getClass());
	System.out.println(myDoc);
	collection.remove(new BasicDBObject("name", "MongoDB"));
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:18,代码来源:MarcMongodbClientTest.java

示例2: testImport

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public synchronized void testImport() throws URISyntaxException, IOException, InterruptedException {
	MarcMongodbClient client = new MarcMongodbClient("localhost" , 27017, "sub_last_print");
	DBCollection collection = client.getCollection("marc");
	assertEquals(0, collection.count());
	boolean insert = true;
	if (insert) {
		JsonPathCache<? extends XmlFieldInstance> cache;
		List<String> records = FileUtils.readLines("general/marc.json");
		for (String record : records) {
			cache = new JsonPathCache<>(record);
			Object jsonObject = jsonProvider.parse(record);
			String id   = cache.get("$.controlfield.[?(@.tag == '001')].content").get(0).getValue();
			String x003 = cache.get("$.controlfield.[?(@.tag == '003')].content").get(0).getValue();

			BasicDBObject doc = new BasicDBObject("type", "marcjson")
				.append("id", id)
				.append("x003", x003)
				.append("record", record);
			collection.insert(doc);
		}
		assertEquals(674, collection.count());
	}
	collection.remove(new BasicDBObject("type", "marcjson"));
	assertEquals(0, collection.count());
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:26,代码来源:MarcMongodbClientTest.java

示例3: DeleteDate

import com.mongodb.DBCollection; //导入方法依赖的package包/类
private int DeleteDate(SQLDeleteStatement state) {
	SQLTableSource table=state.getTableSource();
	DBCollection coll =this._db.getCollection(table.toString());
	
	SQLExpr expr=state.getWhere();
	if (expr==null) {
		throw new RuntimeException("not where of sql");
	}
	DBObject query = parserWhere(expr);
	
	coll.remove(query);
	
	return 1;
	
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:16,代码来源:MongoSQLParser.java

示例4: deleteUser

import com.mongodb.DBCollection; //导入方法依赖的package包/类
/**
 * Delete a user.
 *
 * @param id The ID of the user to delete.
 * @return Nothing.
 */
@DELETE
@Path("/{id}")
public Response deleteUser(@PathParam("id") String id) {
  // Validate the JWT.  The JWT must be in the 'users' group.  We do not check
  // to see if the user is deleting their own profile.
  try {
    validateJWT(new HashSet<String>(Arrays.asList("users")));
  } catch (JWTException jwte) {
    return Response.status(Status.UNAUTHORIZED)
        .type(MediaType.TEXT_PLAIN)
        .entity(jwte.getMessage())
        .build();
  }

  // Retrieve the user from the database.
  DB database = mongo.getMongoDB();
  DBCollection dbCollection = database.getCollection(User.DB_COLLECTION_NAME);
  ObjectId dbId = new ObjectId(id);
  DBObject dbUser = dbCollection.findOne(dbId);

  // If the user did not exist, return an error.  Otherwise, remove the user.
  if (dbUser == null) {
    return Response.status(Status.BAD_REQUEST).entity("The user name was not Found.").build();
  }

  dbCollection.remove(new BasicDBObject(User.DB_ID, dbId));
  return Response.ok().build();
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:35,代码来源:UserResource.java

示例5: testInsert

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public void testInsert() throws UnknownHostException {
	MarcMongodbClient client = new MarcMongodbClient("localhost" , 27017, "sub_last_print");
	DBCollection collection = client.getCollection("marc");
	BasicDBObject doc = createTestObject();
	collection.insert(doc);
	assertNotNull(collection);
	assertEquals(1, collection.count());
	collection.remove(new BasicDBObject("name", "MongoDB"));
	assertEquals(0, collection.count());
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:11,代码来源:MarcMongodbClientTest.java

示例6: delete

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public int delete(DBCollection collection, WriteConcern writeConcern) {
	DBObject query = new BasicDBObject();
	if (null != condition) {
		this.condition.setQuery(query, null);
	}

	log(query);

	// WriteResult result = collection.remove(query, WriteConcern.ACKNOWLEDGED);
	WriteResult result = collection.remove(query, writeConcern);
	// collection.remove(query)
	// System.out.println(query.toString());
	return result.getN();
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:15,代码来源:DeleteVo.java

示例7: flushInvalid

import com.mongodb.DBCollection; //导入方法依赖的package包/类
protected void flushInvalid(DBCollection coll,BasicDBObject query) {
	if(coll==null) coll=getCollection();
	BasicDBObject q = (BasicDBObject) query.clone();

	//execute the query
	q.append("expires", new BasicDBObject("$lt", System.currentTimeMillis()).append("$gt", 0));
	coll.remove(q);

}
 
开发者ID:lucee,项目名称:extension-mongodb,代码行数:10,代码来源:MongoDBCache.java

示例8: delete

import com.mongodb.DBCollection; //导入方法依赖的package包/类
/**
   * 删除
   * @param dbName
   * @param collName
   * @param dbObject
   */
  public static void delete(String dbName, String collName, DBObject dbObject) {
  	DBCollection collection = getCollection(dbName, collName);
  	if (collection != null) {
  		collection.remove(dbObject);
}
  }
 
开发者ID:xuxueli,项目名称:xxl-incubator,代码行数:13,代码来源:MongoDBUtil.java

示例9: run

import com.mongodb.DBCollection; //导入方法依赖的package包/类
@Override
public void run() {
    MongoCollection collection = getMongoCollection();
    DBCollection dbCollection = collection.getDBCollection();
    String field = getField();
    Object value = getValue();
    if(Settings.getInstance().isDebug()) {
        System.out.println("(" + dbCollection.getName() + "): Deleting Document (Field:" + field + " Value:" + value + ")");
    }
    dbCollection.remove(new BasicDBObject(field, value));
}
 
开发者ID:JabJabJab,项目名称:Sledgehammer,代码行数:12,代码来源:MongoDocumentTransactionDelete.java

示例10: doRemove

import com.mongodb.DBCollection; //导入方法依赖的package包/类
/**
 * Perform a single 'remove' operation on the local object store.
 *
 * @param ref  Object reference string of the object to be deleted.
 * @param collection  Collection to remove from.
 *
 * @return a ResultDesc object describing the success or failure of the
 *    operation.
 */
private ResultDesc doRemove(String ref, DBCollection collection) {
    String failure = null;
    try {
        DBObject query = new BasicDBObject();
        query.put("ref", ref);
        collection.remove(query);
    } catch (Exception e) {
        failure = e.getMessage();
    }
    return new ResultDesc(ref, failure);
}
 
开发者ID:FUDCo,项目名称:Elko,代码行数:21,代码来源:MongoObjectStore.java

示例11: update

import com.mongodb.DBCollection; //导入方法依赖的package包/类
/**
 * Method to update an existing node category entity.
 * 
 * @param objectToUpdate	Node category entity to update.
 * @param targetCollection	Collection where the node category entity
 * 							is located in the database.
 */
public void update(final DBObject objectToUpdate, final DBCollection targetCollection) {
  targetCollection.remove(objectToUpdate);
  DBObject _dbObject = this.getDbObject();
  targetCollection.save(_dbObject);
  String _name = this.getName();
  String _plus = (_name + 
    " node category has been updated.");
  ConfigSpaceGenerator.LOGGER.info(_plus);
}
 
开发者ID:visor-vu,项目名称:chariot,代码行数:17,代码来源:DM_NodeCategory.java

示例12: update

import com.mongodb.DBCollection; //导入方法依赖的package包/类
/**
 * Method to update an existing component type entity.
 * 
 * @param objectToUpdate	Component type entity to update.
 * @param targetCollection	Collection where the component type entity
 * 							is located in the database.
 */
public void update(final DBObject objectToUpdate, final DBCollection targetCollection) {
  targetCollection.remove(objectToUpdate);
  DBObject _dbObject = this.getDbObject();
  targetCollection.save(_dbObject);
  String _name = this.getName();
  String _plus = (_name + 
    " component type has been updated.");
  ConfigSpaceGenerator.LOGGER.info(_plus);
}
 
开发者ID:visor-vu,项目名称:chariot,代码行数:17,代码来源:DM_ComponentType.java

示例13: update

import com.mongodb.DBCollection; //导入方法依赖的package包/类
/**
 * Method to update an existing goal description entity.
 * 
 * @param objectToUpdate	Goal description entity to update.
 * @param targetCollection	Collection where the goal description entity
 * 							is located in the database.
 */
public void update(final DBObject objectToUpdate, final DBCollection targetCollection) {
  targetCollection.remove(objectToUpdate);
  DBObject _dbObject = this.getDbObject();
  targetCollection.save(_dbObject);
  String _name = this.getName();
  String _plus = (_name + 
    " goal has been updated.");
  ConfigSpaceGenerator.LOGGER.info(_plus);
}
 
开发者ID:visor-vu,项目名称:chariot,代码行数:17,代码来源:DM_GoalDescription.java

示例14: doDelete

import com.mongodb.DBCollection; //导入方法依赖的package包/类
private void doDelete(DBObject obj) {
	DBCollection coll = getCollection();
	coll.remove(obj);
}
 
开发者ID:lucee,项目名称:extension-mongodb,代码行数:5,代码来源:MongoDBCache.java


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