public Object doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException { DeleteResult dr = collection.deleteMany(dbQuery); return null; } });
@Override public void abort() { synchronized (closeLock) { checkClosed(); closed = true; } if (clientSession != null) { chunksCollection.deleteMany(clientSession, new Document("files_id", fileId)); } else { chunksCollection.deleteMany(new Document("files_id", fileId)); } }
@Signature public long deleteMany(BasicDBObject filter) { return getWrappedObject().deleteMany(filter).getDeletedCount(); }
private void executeDelete(@Nullable final ClientSession clientSession, final BsonValue id) { DeleteResult result; if (clientSession != null) { result = filesCollection.deleteOne(clientSession, new BsonDocument("_id", id)); chunksCollection.deleteMany(clientSession, new BsonDocument("files_id", id)); } else { result = filesCollection.deleteOne(new BsonDocument("_id", id)); chunksCollection.deleteMany(new BsonDocument("files_id", id)); } if (result.wasAcknowledged() && result.getDeletedCount() == 0) { throw new MongoGridFSException(format("No file found with the id: %s", id)); } }
result = collection.deleteOne(query); } else { result = collection.deleteMany(query);
: collection; DeleteResult result = multi ? collectionToUse.deleteMany(removeQuery, options) : collection.deleteOne(removeQuery, options);
@Override public long delete(Map<String, Object> query) { DeleteResult result = collection.deleteMany(new Document(query)); return result.wasAcknowledged() ? result.getDeletedCount() : -result.getDeletedCount(); }
public void importData(ServerConfiguration configuration, MongoCollection mongoCollection, List<Document> mongoDocuments, boolean replaceAllDocuments) { Task task = mongoClient -> { MongoDatabase mongoDatabase = mongoCollection.getParentDatabase(); com.mongodb.client.MongoDatabase database = mongoClient.getDatabase(mongoDatabase.getName()); com.mongodb.client.MongoCollection<Document> collection = database.getCollection(mongoCollection.getName()); if (replaceAllDocuments) { collection.deleteMany(EMPTY_DOC); } collection.insertMany(mongoDocuments); }; executeTask(configuration, task); }
public Object doInCollection(MongoCollection<Document> collection) throws MongoException, DataAccessException { DeleteResult dr = collection.deleteMany(dbQuery); return null; } });
: collection; DeleteResult result = multi ? collectionToUse.deleteMany(removeQuery, options) : collection.deleteOne(removeQuery, options);
/** Clear all collections. */ public void clear() { interactions.deleteMany(new Document()); relationTypes.deleteMany(new Document()); } }
@Override public void abort() { synchronized (closeLock) { checkClosed(); closed = true; } if (clientSession != null) { chunksCollection.deleteMany(clientSession, new Document("files_id", fileId)); } else { chunksCollection.deleteMany(new Document("files_id", fileId)); } }
peopleCollection.deleteMany(new Document()); peopleCollection.insertMany(Arrays.asList( new Document()
/** {@inheritDoc} */ @Override public void clear() { getFeaturesCollection().deleteMany(new Document()); }
@Override public void deleteAll(Collection<String> keys) { this.collection.deleteMany(in("_id", keys)); } }
protected void deleteReferences(String... stages) { Document document = new Document(); List<String> list = Arrays.asList(stages); document.put(IMongoSerializer.FIELD_STAGE, new Document("$in", list)); collRefs.deleteMany(document); }
@BeforeClass public static void setUp() throws Exception { TestUtil.ignoreException(() -> { mongo = new GenericContainer("mongo:3") .withNetworkAliases("mongo-" + Base58.randomString(6)) .withExposedPorts(MONGO_DEFAULT_PORT) .waitingFor(new HttpWaitStrategy() .forPort(MONGO_DEFAULT_PORT) .forStatusCodeMatching(response -> response == HTTP_OK || response == HTTP_UNAUTHORIZED) .withStartupTimeout(Duration.ofMinutes(2))); mongo.start(); }, Exception.class); assumeNotNull(mongo); assumeTrue("Mongo DB must be running", mongo.isRunning()); MongoClient mongoClient = new MongoClient(mongo.getContainerIpAddress(), mongo.getMappedPort(MONGO_DEFAULT_PORT)); HOST = String.format("mongodb://%s:%s", mongo.getContainerIpAddress(), mongo.getMappedPort(MONGO_DEFAULT_PORT)); params = map("host", HOST, "db", "test", "collection", "test"); MongoDatabase database = mongoClient.getDatabase("test"); collection = database.getCollection("test"); collection.deleteMany(new Document()); collection.insertOne(new Document(map("name", "testDocument", "date", currentTime, "longValue", longValue))); db = new TestGraphDatabaseFactory() .newImpermanentDatabaseBuilder() .newGraphDatabase(); TestUtil.registerProcedure(db, MongoDB.class); mongoClient.close(); }
private void deleteAllElements(MongoDatabase mongoDb) { final MongoIterable<String> listCollectionNames = mongoDb.listCollectionNames(); for (String collectionName : listCollectionNames) { if (isNotASystemCollection(collectionName)) { LOGGER.debug("Dropping Collection {}.", collectionName); MongoCollection dbCollection = mongoDb.getCollection(collectionName); // Delete ALL, No DROP dbCollection.deleteMany(new Document()); } } }
@ManagedOperation(description = "Clear the store") @Override public void clear() { collection.deleteMany(new BsonDocument()); }
@NotNull @Override public DeleteResult deleteMany(@NotNull ClientSession clientSession, @NotNull Bson filter) { maybeThrowExceptionBeforeUpdate(); DeleteResult result = collection.deleteMany(clientSession, filter); maybeThrowExceptionAfterUpdate(); return result; }