Tabnine Logo
AbstractMongoRepository.collection
Code IndexAdd Tabnine to your IDE (free)

How to use
collection
method
in
de.otto.edison.mongo.AbstractMongoRepository

Best Java code snippets using de.otto.edison.mongo.AbstractMongoRepository.collection (Showing top 20 results out of 315)

origin: de.otto.edison/mongo

public long size() {
  return collection().count();
}
origin: de.otto.edison/edison-mongo

protected MongoCollection<Document> collectionWithWriteTimeout(long maxTime, TimeUnit timeUnit) {
  return collection()
      .withWriteConcern(collection().getWriteConcern().withWTimeout(maxTime, timeUnit));
}
origin: otto-de/edison-microservice

protected MongoCollection<Document> collectionWithWriteTimeout(long maxTime, TimeUnit timeUnit) {
  return collection()
      .withWriteConcern(collection().getWriteConcern().withWTimeout(maxTime, timeUnit));
}
origin: de.otto.edison/mongo

public void delete(final K key) {
  collection().deleteOne(byId(key));
}
origin: de.otto.edison/mongo

public List<V> findAll() {
  return collection()
      .find()
      .map(this::decode)
      .into(new ArrayList<>());
}
origin: otto-de/edison-microservice

public Stream<V> findAllAsStream(final long maxTime, final TimeUnit timeUnit) {
  return toStream(
      collection().find()
          .maxTime(maxTime, timeUnit))
      .map(this::decode);
}
origin: de.otto.edison/mongo

public void deleteAll() {
  collection().deleteMany(matchAll());
}
origin: de.otto.edison/edison-mongo

public Stream<V> findAllAsStream(final long maxTime, final TimeUnit timeUnit) {
  return toStream(
      collection().find()
          .maxTime(maxTime, timeUnit))
      .map(this::decode);
}
origin: de.otto.edison/mongo

public Optional<V> findOne(final K key) {
  return ofNullable(collection()
      .find(byId(key))
      .map(this::decode)
      .first());
}
origin: de.otto.edison/edison-mongo

private FindIterable<Document> getFindIterable(int skip, int limit) {
  return collection()
      .find()
      .skip(skip)
      .limit(limit);
}
origin: de.otto.edison/mongo

public V createOrUpdate(final V value) {
  final K key = keyOf(value);
  final Document existing = collection().find(byId(key)).first();
  Document doc = encode(value);
  if (existing != null) {
    collection().replaceOne(byId(key), doc);
  } else {
    collection().insertOne(doc);
  }
  return decode(doc);
}
origin: de.otto.edison/mongo

public V create(final V value) {
  Document doc = encode(value);
  collection().insertOne(doc);
  return decode(doc);
}
origin: otto-de/edison-microservice

private FindIterable<Document> getFindIterable(int skip, int limit) {
  return collection()
      .find()
      .skip(skip)
      .limit(limit);
}
origin: de.otto.edison/mongo

public List<V> findAll(int skip, int limit) {
  return collection()
      .find()
      .skip(skip)
      .limit(limit)
      .map(this::decode)
      .into(new ArrayList<>());
}
origin: de.otto.edison/edison-mongo

/**
 * Find a single value with the specified key, if existing.
 *
 * @param key      the key to search for
 * @param maxTime  the maximum time for this request
 * @param timeUnit the time unit in which {@code maxTime} is specified
 * @return an Optional containing the requested value, or {@code Optional.empty()} if no value with this key exists
 */
public Optional<V> findOne(final K key, final long maxTime, final TimeUnit timeUnit) {
  return ofNullable(collection()
      .find(byId(key))
      .maxTime(maxTime, timeUnit)
      .map(this::decode)
      .first());
}
origin: de.otto.edison/mongo

public void update(final V value) {
  final K key = keyOf(value);
  collection().replaceOne(byId(key), encode(value));
}
origin: otto-de/edison-microservice

/**
 * Find a single value with the specified key, if existing.
 *
 * @param key      the key to search for
 * @param maxTime  the maximum time for this request
 * @param timeUnit the time unit in which {@code maxTime} is specified
 * @return an Optional containing the requested value, or {@code Optional.empty()} if no value with this key exists
 */
public Optional<V> findOne(final K key, final long maxTime, final TimeUnit timeUnit) {
  return ofNullable(collection()
      .find(byId(key))
      .maxTime(maxTime, timeUnit)
      .map(this::decode)
      .first());
}
origin: otto-de/edison-microservice

public long size(final long maxTime, final TimeUnit timeUnit) {
  return collection().countDocuments(new BsonDocument(), new CountOptions().maxTime(maxTime, timeUnit));
}
origin: de.otto.edison/edison-mongo

public long size(final long maxTime, final TimeUnit timeUnit) {
  return collection().count(new BsonDocument(), new CountOptions().maxTime(maxTime, timeUnit));
}
origin: de.otto.edison/mongo

public void updateIfMatch(final V value, final String eTag) {
  Bson query = and(eq(AbstractMongoRepository.ID, keyOf(value)), eq(ETAG, eTag));
  Document updatedETaggable = collection().findOneAndReplace(query, encode(value), new FindOneAndReplaceOptions().returnDocument(AFTER));
  if (isNull(updatedETaggable)) {
    Optional<V> findById = findOne(keyOf(value));
    if (findById.isPresent()) {
      throw new ConcurrentModificationException("Entity concurrently modified: " + keyOf(value));
    }
    throw new NotFoundException("Entity does not exist: " + keyOf(value));
  }
}
de.otto.edison.mongoAbstractMongoRepositorycollection

Popular methods of AbstractMongoRepository

  • byId
    Returns a query that is selecting documents by ID.
  • decode
    Decode a MongoDB Document into a value.
  • encode
    Encode a value into a MongoDB Document.
  • findOne
    Find a single value with the specified key, if existing.
  • keyOf
    Returns the key / identifier from the given value. The key of a document must never be null.
  • matchAll
    Returns a query that is selecting all documents.
  • collectionWithWriteTimeout
  • create
  • createOrUpdate
  • createOrUpdateBulk
  • delete
    Deletes the document identified by key.
  • deleteAll
    Deletes all documents from this repository.
  • delete,
  • deleteAll,
  • ensureIndexes,
  • findAll,
  • findAllAsStream,
  • getFindIterable,
  • size,
  • toStream,
  • update

Popular in Java

  • Making http post requests using okhttp
  • runOnUiThread (Activity)
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now