Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public interface DocumentStore
ExtendsAutoCloseable, Closeable
Known subtypesDynamoDocumentStore, MongoDocumentStore
The operations DocumentSession needs of a document database.
A document is a Map of strings, numbers, booleans, dates and byte arrays.
Its key is held in the fields named by keyFields: one field, the partition
key, or two, the partition key and then the sort key. A key value is a
String or a Number, given as an array in the same order as keyFields.
Methods
Method details
ensureCollection
public abstract void ensureCollection(String collection, String[] keyFields, boolean[] numericKeys)
throws IOExceptionPrepares a collection keyed by
keyFields, each a number where
numericKeys says so and a string otherwise; an existing one is kept.Throws
insert
public abstract boolean insert(String collection, String[] keyFields, Map document)
throws IOExceptionInserts a new document; returns false when one with the same key exists.
Throws
replace
public abstract boolean replace(String collection, String[] keyFields, Map document, String versionField, Object expectedVersion)
throws IOExceptionReplaces the document with the same key. When
versionField is not null
it replaces only a document whose version is expectedVersion. Returns
whether a document was replaced.Throws
get
public abstract Map get(String collection, String[] keyFields, Object[] key)
throws IOExceptionThe document with this key, or null.
Throws
delete
public abstract boolean delete(String collection, String[] keyFields, Object[] key, String versionField, Object expectedVersion)
throws IOExceptionDeletes the document with this key; returns whether there was one. A
non-null
versionField deletes only the version expectedVersion.Throws
find
public abstract List find(String collection, String[] keyFields, List criteria, String sortField, boolean ascending, int offset, int limit)
throws IOExceptionThe documents matching every criterion, ordered by
sortField (null for
the store’s order), skipping offset and returning at most limit
(negative for no limit).Throws
count
public abstract long count(String collection, String[] keyFields, List criteria)
throws IOExceptionHow many documents match every criterion.
Throws
newId
public abstract String newId()A new identifier for a document whose id is generated.
close
public abstract void close()Releases the store’s connections.