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

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

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

origin: otto-de/edison-microservice

/**
 * 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));
}
origin: de.otto.edison/edison-mongo

/**
 * 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));
}
origin: de.otto.edison/mongo

public void delete(final K key) {
  collection().deleteOne(byId(key));
}
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

/**
 * 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: de.otto.edison/edison-mongo

/**
 * 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");
  }
}
origin: otto-de/edison-microservice

/**
 * 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");
  }
}
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/edison-mongo

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);
}
origin: otto-de/edison-microservice

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);
}
de.otto.edison.mongoAbstractMongoRepositorybyId

Javadoc

Returns a query that is selecting documents by ID.

Popular methods of AbstractMongoRepository

  • collection
  • 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

  • Parsing JSON documents to java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Best IntelliJ plugins
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