Example usage for com.mongodb DBCollection findAndModify

List of usage examples for com.mongodb DBCollection findAndModify

Introduction

In this page you can find the example usage for com.mongodb DBCollection findAndModify.

Prototype

@Nullable
public DBObject findAndModify(@Nullable final DBObject query, @Nullable final DBObject sort,
        final DBObject update) 

Source Link

Document

Atomically modify and return a single document.

Usage

From source file:com.norconex.collector.http.data.store.impl.mongo.MongoCrawlDataSerializer.java

License:Apache License

@Override
public DBObject getNextQueued(DBCollection collRefs) {
    BasicDBObject whereQuery = new BasicDBObject(FIELD_STAGE, Stage.QUEUED.name());
    BasicDBObject sort = new BasicDBObject(FIELD_DEPTH, 1);
    BasicDBObject newDocument = new BasicDBObject("$set", new BasicDBObject(FIELD_STAGE, Stage.ACTIVE.name()));
    return collRefs.findAndModify(whereQuery, sort, newDocument);
}