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


Java DeleteResult.getDeletedCount方法代码示例

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


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

示例1: deleteById

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
/**
 * 删除记录
 * 
 * @param collectionName
 *            表名
 * @param mongoObj
 *            记录
 * @return
 */
public static boolean deleteById(String collectionName, MongoObj mongoObj) {
	MongoCollection<Document> collection = getCollection(collectionName);
	try {
		Bson filter = Filters.eq(MongoConfig.MONGO_ID, mongoObj.getDocument().getObjectId(MongoConfig.MONGO_ID));
		DeleteResult result = collection.deleteOne(filter);
		if (result.getDeletedCount() == 1) {
			return true;
		} else {
			return false;
		}
	} catch (Exception e) {
		if (log != null) {
			log.error("删除记录失败", e);
		}
		return false;
	}

}
 
开发者ID:dianbaer,项目名称:grain,代码行数:28,代码来源:MongodbManager.java

示例2: delete

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
/**
 * Delete the data in mongo by the query.
 *
 * @param collection
 *            the collection
 * @param q
 *            the q
 * @param db
 *            the db
 * @return the long
 */
public int delete(String collection, W q, String db) {
	int n = -1;
	try {
		MongoCollection<Document> db1 = getCollection(db, collection);
		if (db != null) {
			DeleteResult r = db1.deleteMany(q.query());
			// db.remove(query);
			n = (int) r.getDeletedCount();
		}

		if (log.isDebugEnabled()) {
			log.debug("delete, collection=" + collection + ", q=" + q + ", deleted=" + n);
		}
	} catch (Exception e) {
		if (log.isErrorEnabled())
			log.error(e.getMessage(), e);
	}
	return n;
}
 
开发者ID:giiwa,项目名称:giiwa,代码行数:31,代码来源:MongoHelper.java

示例3: deletePointsFromSeriesByPointKey

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public boolean deletePointsFromSeriesByPointKey(String key, List<String> pointKeys) {
    MongoCollection<Document> collection = getCollection(key);
    boolean ret = false;
    for (String pointKey : pointKeys) {
        Document victim = new Document(ROWKEY, key).append(COLKEY, pointKey);
        try {
            DeleteResult result = collection.deleteMany(victim);
            log.info("Removed " + result.getDeletedCount() + " rows");
            ret = (result.getDeletedCount() > 0);
        } catch (MongoException me) {
            throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, new ExceptionToString(me));
        }
    }
    return ret;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:17,代码来源:MongoSeriesStore.java

示例4: removeSuite

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public boolean removeSuite(DBKey dbKey, String correlationId, Long version)
    throws StorageException {
  LOGGER
      .debug("Removing suite with correlationId {}, version {} from {}.", correlationId, version,
          dbKey);
  MongoCollection<Document> metadata = getMetadataCollection(dbKey);

  final DeleteResult deleteResult = metadata.deleteOne(
      Filters.and(
          Filters.eq(CORRELATION_ID_PARAM_NAME, correlationId),
          Filters.eq(SUITE_VERSION_PARAM_NAME, version)
      ));

  return deleteResult.getDeletedCount() == 1;
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:17,代码来源:MetadataDAOMongoDBImpl.java

示例5: deleteById

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
public static int deleteById(MongoCollection<Document> col, Object id) {
    int count = 0;
    Bson filter = Filters.eq("_id", id);
    DeleteResult deleteResult = col.deleteOne(filter);
    count = (int) deleteResult.getDeletedCount();
    return count;
}
 
开发者ID:jiumao-org,项目名称:wechat-mall,代码行数:8,代码来源:MongoCRUD.java

示例6: executeQuery

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
long executeQuery(int threadId, long threadRunCount, long globalRunCount, long selectorId, long randomId) {

    final DeleteResult res = THREAD_RUN_COUNT.equals(queriedField)?mongoCollection.deleteMany(eq(queriedField, selectorId))
            :ID.equals(queriedField)?mongoCollection.deleteOne(eq(queriedField, selectorId)):null;
    return res!=null?res.getDeletedCount():0l;

}
 
开发者ID:idealo,项目名称:mongodb-performance-test,代码行数:9,代码来源:DeleteOperation.java

示例7: delete

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public void delete(String oid) throws DataNotFoundException {
	DeleteResult deleteResult = this.collection.deleteOne(eq("_id", new ObjectId(oid)));
	if (deleteResult.getDeletedCount() == 0) {
		throw new DataNotFoundException(new Throwable("File with id " + oid + " not found"));

	}

}
 
开发者ID:ccem-dev,项目名称:otus-api,代码行数:10,代码来源:FileUploaderDaoBean.java

示例8: delete

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public void delete(String name) throws DataNotFoundException {
    BasicDBObject query = new BasicDBObject();
    query.put("objectType", "ActivityCategory");
    query.put("name", name);

    DeleteResult deleteResult = collection.deleteOne(query);

    if (deleteResult.getDeletedCount() == 0) {
        throw new DataNotFoundException(
                new Throwable("ActivityCategory {" + name + "} not found."));        }
}
 
开发者ID:ccem-dev,项目名称:otus-api,代码行数:13,代码来源:ActivityConfigurationDaoBean.java

示例9: delete

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public void delete(String id) throws DataNotFoundException {
	DeleteResult deleteResult = collection.deleteOne(eq("code", id));
	if (deleteResult.getDeletedCount() == 0) {
		throw new DataNotFoundException(new Throwable("Exam Lot does not exist"));
	}
}
 
开发者ID:ccem-dev,项目名称:otus-api,代码行数:8,代码来源:ExamLotDaoBean.java

示例10: delete

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public void delete(String id) throws DataNotFoundException{
	DeleteResult deleteResult = collection.deleteOne(eq("code", id));
	if (deleteResult.getDeletedCount() == 0) {
		 throw new DataNotFoundException(new Throwable("Transportation Lot does not exist"));
	}
}
 
开发者ID:ccem-dev,项目名称:otus-api,代码行数:8,代码来源:TransportationLotDaoBean.java

示例11: delete

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public <T> void delete(T t) {
    MongoModel mongoModel = (MongoModel) t;
    MongoCollection<Document> collection = database.getCollection(t.getClass().getSimpleName());
    BasicDBObject query = new BasicDBObject(MongoModel.OID, mongoModel.getObjectId());
    DeleteResult deleteResult = collection.deleteOne(query);
    if (deleteResult.getDeletedCount() != 1) {
        Log.error("error while deleting from db, total delete count: " + deleteResult.getDeletedCount());
    }
}
 
开发者ID:canmogol,项目名称:FatJar,代码行数:11,代码来源:MongoDB.java

示例12: deleteDocument

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
public static void deleteDocument(Bson filter, Optional<String> hash, MongoCollection<Document> collection) {

    if (hash.isPresent()) {
      filter = Filters.and(
        filter,
        Filters.eq("meta.hash", hash.get())
      );
    }
    final DeleteResult result = collection.deleteOne(filter);
    if (result.getDeletedCount() != 1) {
      throw new WebApplicationException("Concurrent modification", 422);
    }
  }
 
开发者ID:atgse,项目名称:sam,代码行数:14,代码来源:MongoHelper.java

示例13: deletePointsFromSeries

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public boolean deletePointsFromSeries(String key) {
    boolean ret = false;
    MongoCollection<Document> collection = getCollection(key);
    Document victim = new Document(ROWKEY, key);
    try {
        DeleteResult result = collection.deleteMany(victim);
        log.info("Removed " + result.getDeletedCount() + " rows");
        ret = (result.getDeletedCount() > 0);
    } catch (MongoException me) {
        throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, new ExceptionToString(me));
    }
    unregisterKey(key);
    return ret;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:16,代码来源:MongoSeriesStore.java

示例14: deleteBlob

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
@Override
public Boolean deleteBlob(CallingContext context, String docPath) {
    log.debug("Removing " + docPath);
    Document query = new Document();
    query.append(BLOB_NAME, docPath);
    try {
        DeleteResult res = getCollection().deleteOne(query);
        return res.getDeletedCount() != 0;
    } catch (MongoException e) {
        log.error("Could not delete " + docPath + ": " + e.getMessage());
        log.debug(ExceptionToString.format(e));
    }
    return false;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:15,代码来源:DocHandler.java

示例15: releaseLockWithID

import com.mongodb.client.result.DeleteResult; //导入方法依赖的package包/类
private Boolean releaseLockWithID(String lockName, String id) {
    Document lockFileQuery = new Document();
    lockFileQuery.put("_id", id);
    MongoCollection<Document> coll = getLockCollection(lockName);
    DeleteResult res = coll.deleteOne(lockFileQuery);

    return (res.getDeletedCount() == 1);
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:9,代码来源:MongoLockHandler2.java


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