Class MongoCollection
java.lang.Object
com.codename1.backend.mongo.MongoCollection
-
Method Summary
Modifier and TypeMethodDescriptionThe results of an aggregation pipeline, a list of stage documents.longcountDocuments(Map filter) How many documentsfiltermatches.createIndex(Map keys, boolean unique) Creates an index overkeys(for example{"email": 1}) unless one exists;uniquemakes a second document with the same key aMongoException.isDuplicateKey()failure.longdeleteMany(Map filter) Deletes every matching document; returns how many were deleted.longDeletes the first matching document; returns how many were deleted.voiddrop()Drops the collection; a missing one is not an error.Every documentfiltermatches.The documentsfiltermatches, ordered bysort(null for none), with only the fields inprojection(null for all), skippingskipand returning at mostlimit(zero for no limit).The first documentfiltermatches, or null.getName()The collection's name.voidinsertMany(List documents) Inserts documents in order, stopping at the first that fails.Inserts one document and returns its_id.voidreplaceOne(Map filter, Map replacement, boolean upsert) Replaces the first matching document, inserting it when none matches.longupdateMany(Map filter, Map update) Appliesupdateto every matching document; returns how many matched.longAppliesupdateto the first matching document; returns how many matched.voidAppliesupdateto the first matching document, or inserts one when none matches.
-
Method Details
-
getName
The collection's name. -
insertOne
Inserts one document and returns its_id.- Throws:
IOException
-
insertMany
Inserts documents in order, stopping at the first that fails.- Throws:
IOException
-
find
-
findOne
The first documentfiltermatches, or null.- Throws:
IOException
-
find
The documentsfiltermatches, ordered bysort(null for none), with only the fields inprojection(null for all), skippingskipand returning at mostlimit(zero for no limit).- Throws:
IOException
-
aggregate
The results of an aggregation pipeline, a list of stage documents.- Throws:
IOException
-
countDocuments
How many documentsfiltermatches.- Throws:
IOException
-
updateOne
Appliesupdateto the first matching document; returns how many matched.- Throws:
IOException
-
updateMany
Appliesupdateto every matching document; returns how many matched.- Throws:
IOException
-
replaceOne
Replaces the first matching document, inserting it when none matches.- Throws:
IOException
-
upsert
Appliesupdateto the first matching document, or inserts one when none matches.- Throws:
IOException
-
deleteOne
Deletes the first matching document; returns how many were deleted.- Throws:
IOException
-
deleteMany
Deletes every matching document; returns how many were deleted.- Throws:
IOException
-
createIndex
Creates an index overkeys(for example{"email": 1}) unless one exists;uniquemakes a second document with the same key aMongoException.isDuplicateKey()failure. Returns the index name.- Throws:
IOException
-
drop
Drops the collection; a missing one is not an error.- Throws:
IOException
-