/** * Deletes all documents from this repository. * * @param maxTime max time for the operation * @param timeUnit the time unit for the maxTime value */ public void deleteAll(final long maxTime, final TimeUnit timeUnit) { collectionWithWriteTimeout(maxTime, timeUnit).deleteMany(matchAll()); }
/** * Deletes the document identified by key. * * @param key the identifier of the deleted document * @param maxTime max time for the operation * @param timeUnit the time unit for the maxTime value */ public void delete(final K key, final long maxTime, final TimeUnit timeUnit) { collectionWithWriteTimeout(maxTime, timeUnit).deleteOne(byId(key)); }
/** * Deletes the document identified by key. * * @param key the identifier of the deleted document * @param maxTime max time for the operation * @param timeUnit the time unit for the maxTime value */ public void delete(final K key, final long maxTime, final TimeUnit timeUnit) { collectionWithWriteTimeout(maxTime, timeUnit).deleteOne(byId(key)); }
/** * Deletes all documents from this repository. * @param maxTime max time for the operation * @param timeUnit the time unit for the maxTime value */ public void deleteAll(final long maxTime, final TimeUnit timeUnit) { collectionWithWriteTimeout(maxTime, timeUnit).deleteMany(matchAll()); }
public void createOrUpdateBulk(final Collection<V> values, final long maxTime, final TimeUnit timeUnit) { if (values.isEmpty()) { return; } final List<ReplaceOneModel<Document>> bulkOperations = values.stream() .map(value -> new ReplaceOneModel<>( eq(ID, keyOf(value)), encode(value), BULK_UPSERT_OPERATION)) .collect(toList()); collectionWithWriteTimeout(maxTime, timeUnit) .bulkWrite(bulkOperations, BULK_WRITE_OPTIONS); }
public void createOrUpdateBulk(final Collection<V> values, final long maxTime, final TimeUnit timeUnit) { if (values.isEmpty()) { return; } final List<ReplaceOneModel<Document>> bulkOperations = values.stream() .map(value -> new ReplaceOneModel<>( eq(ID, keyOf(value)), encode(value), BULK_UPSERT_OPERATION)) .collect(toList()); collectionWithWriteTimeout(maxTime, timeUnit) .bulkWrite(bulkOperations, BULK_WRITE_OPTIONS); }
public V create(final V value, final long maxTime, final TimeUnit timeUnit) { final K key = keyOf(value); if (key != null) { final Document doc = encode(value); collectionWithWriteTimeout(maxTime, timeUnit).insertOne(doc); return decode(doc); } else { throw new NullPointerException("Key must not be null"); } }
public V create(final V value, final long maxTime, final TimeUnit timeUnit) { final K key = keyOf(value); if (key != null) { final Document doc = encode(value); collectionWithWriteTimeout(maxTime, timeUnit).insertOne(doc); return decode(doc); } else { throw new NullPointerException("Key must not be null"); } }
/** * Updates the document if it is already present in the repository. * * @param value the new value * @param maxTime max time for the update * @param timeUnit the time unit for the maxTime value * @return true, if the document was updated, false otherwise. */ public boolean update(final V value, final long maxTime, final TimeUnit timeUnit) { final K key = keyOf(value); if (key != null) { return collectionWithWriteTimeout(maxTime, timeUnit) .replaceOne(byId(key), encode(value)) .getModifiedCount() == 1; } else { throw new IllegalArgumentException("Key must not be null"); } }
/** * Updates the document if it is already present in the repository. * * @param value the new value * @param maxTime max time for the update * @param timeUnit the time unit for the maxTime value * @return true, if the document was updated, false otherwise. */ public boolean update(final V value, final long maxTime, final TimeUnit timeUnit) { final K key = keyOf(value); if (key != null) { return collectionWithWriteTimeout(maxTime, timeUnit) .replaceOne(byId(key), encode(value)) .getModifiedCount() == 1; } else { throw new IllegalArgumentException("Key must not be null"); } }
public V createOrUpdate(final V value, final long maxTime, final TimeUnit timeUnit) { final Document doc = encode(value); collectionWithWriteTimeout(maxTime, timeUnit) .replaceOne(byId(keyOf(value)), doc, new UpdateOptions().upsert(true)); return decode(doc); }
public V createOrUpdate(final V value, final long maxTime, final TimeUnit timeUnit) { final Document doc = encode(value); collectionWithWriteTimeout(maxTime, timeUnit) .replaceOne(byId(keyOf(value)), doc, new ReplaceOptions().upsert(true)); return decode(doc); }
final Bson query = and(eq(AbstractMongoRepository.ID, key), eq(ETAG, eTag)); final Document updatedETaggable = collectionWithWriteTimeout(maxTime, timeUnit).findOneAndReplace(query, encode(value), new FindOneAndReplaceOptions().returnDocument(AFTER)); if (isNull(updatedETaggable)) { final boolean documentExists = collection()
final Bson query = and(eq(AbstractMongoRepository.ID, key), eq(ETAG, eTag)); final Document updatedETaggable = collectionWithWriteTimeout(maxTime, timeUnit).findOneAndReplace(query, encode(value), new FindOneAndReplaceOptions().returnDocument(AFTER)); if (isNull(updatedETaggable)) { final boolean documentExists = collection()