Codota Logo
AbstractMongoRepository.byId
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
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

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • putExtra (Intent)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • Reference (javax.naming)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now