List of usage examples for com.mongodb.client MongoCollection findOneAndReplace
@Nullable TDocument findOneAndReplace(ClientSession clientSession, Bson filter, TDocument replacement);
From source file:my.beesyn.MongoConn.java
public void insert_or_update(Identifier idf, MongoCollection coll) { Document dc;/*from w w w.j a va2 s . c o m*/ FindOneAndReplaceOptions op = new FindOneAndReplaceOptions(); op.upsert(true); dc = Document.parse(idf.get_fetched()); dc.append("u_id", idf.get_id()); dc.append("chsum", dc.hashCode()); coll.findOneAndReplace(Filters.and(Filters.eq("u_id", idf.get_id()), Filters.ne("chsum", idf.get_chk())), dc, op); }
From source file:org.axonframework.mongo.eventsourcing.eventstore.AbstractMongoEventStorageStrategy.java
License:Apache License
@Override public void appendSnapshot(MongoCollection<Document> snapshotCollection, DomainEventMessage<?> snapshot, Serializer serializer) {/*from w w w.jav a 2s. c o m*/ snapshotCollection.findOneAndReplace( new BsonDocument(eventConfiguration.aggregateIdentifierProperty(), new BsonString(snapshot.getAggregateIdentifier())), createSnapshotDocument(snapshot, serializer), new FindOneAndReplaceOptions().upsert(true)); }