Class MongoDocumentStore

java.lang.Object
com.codename1.backend.document.MongoDocumentStore
All Implemented Interfaces:
DocumentStore, Closeable, AutoCloseable

public final class MongoDocumentStore extends Object implements DocumentStore
DocumentStore over MongoDB: the identifier is stored as _id, criteria become a query filter, and sorting and paging run on the server.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MongoDocumentStore(MongoClient client, MongoDatabase database, boolean ownsClient)
    A store over database of client (null for the database the connection string names); ownsClient closes the client with it.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Releases the store's connections.
    long
    count(String collection, String[] keyFields, List criteria)
    How many documents match every criterion.
    boolean
    delete(String collection, String[] keyFields, Object[] key, String versionField, Object expectedVersion)
    Deletes the document with this key; returns whether there was one.
    void
    ensureCollection(String collection, String[] keyFields, boolean[] numericKeys)
    Prepares a collection keyed by keyFields, each a number where numericKeys says so and a string otherwise; an existing one is kept.
    find(String collection, String[] keyFields, List criteria, String sortField, boolean ascending, int offset, int limit)
    The documents matching every criterion, ordered by sortField (null for the store's order), skipping offset and returning at most limit (negative for no limit).
    get(String collection, String[] keyFields, Object[] key)
    The document with this key, or null.
    boolean
    insert(String collection, String[] keyFields, Map document)
    Inserts a new document; returns false when one with the same key exists.
    A new identifier for a document whose id is generated.
    boolean
    replace(String collection, String[] keyFields, Map document, String versionField, Object expectedVersion)
    Replaces the document with the same key.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MongoDocumentStore

      public MongoDocumentStore(MongoClient client, MongoDatabase database, boolean ownsClient)
      A store over database of client (null for the database the connection string names); ownsClient closes the client with it.
  • Method Details