MongoCollection
Allows you to interact with MongoDB collections.
countDocuments
countDocuments() : long
Description
Counts the number of documents in the collection.
How To Use
collection.countDocuments();
Return
( long )
The number of documents in the collection.
countDocuments(filter: org.bson.conversions.Bson) : long
Description
Counts the number of documents in the collection.
How To Use
collection.countDocuments(_mongo.filters().eq('category', 'main'));
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | The query filter. |
Return
( long )
The number of documents in the collection.
countDocuments(filter: org.bson.conversions.Bson, options: com.mongodb.client.model.CountOptions) : long
Description
Counts the number of documents in the collection.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | The query filter. |
| options | com.mongodb.client.model.CountOptions | The options describing the count. |
Return
( long )
The number of documents in the collection.
createIndex
createIndex(keys: org.bson.conversions.Bson) : string
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| keys | org.bson.conversions.Bson |
Return
( string )
deleteMany
deleteMany(filter: org.bson.conversions.Bson) : void
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson |
Return
( void )
deleteMany(filter: org.bson.conversions.Bson, options: com.mongodb.client.model.DeleteOptions) : void
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| options | com.mongodb.client.model.DeleteOptions |
Return
( void )
deleteOne
deleteOne(filter: org.bson.conversions.Bson) : void
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson |
Return
( void )
deleteOne(filter: org.bson.conversions.Bson, options: com.mongodb.client.model.DeleteOptions) : void
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| options | com.mongodb.client.model.DeleteOptions |
Return
( void )
drop
drop() : void
Description
Drops this collection from the Database.
Return
( void )
drop(options: com.mongodb.client.model.DropCollectionOptions) : void
Description
Drops this collection from the Database.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| options | com.mongodb.client.model.DropCollectionOptions | Various options for dropping the collection. |
Return
( void )
estimatedDocumentCount
estimatedDocumentCount() : long
Description
Gets an estimate of the count of documents in a collection using collection metadata.
How To Use
collection.countDocuments();
Return
( long )
The number of documents in the collection.
estimatedDocumentCount(options: com.mongodb.client.model.EstimatedDocumentCountOptions) : long
Description
Gets an estimate of the count of documents in a collection using collection metadata.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| options | com.mongodb.client.model.EstimatedDocumentCountOptions | The options describing the count. |
Return
( long )
The number of documents in the collection.
find
find() : MongoFindIterable
Description
Finds all documents in the collection.
Return
The find iterable interface.
find(filter: org.bson.conversions.Bson) : MongoFindIterable
Description
Finds all documents in the collection.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | The query filter. |
Return
The find iterable interface.
findOneAndDelete
findOneAndDelete(filter: org.bson.conversions.Bson) : Values
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson |
Return
( Values )
findOneAndDelete(filter: org.bson.conversions.Bson, options: com.mongodb.client.model.FindOneAndDeleteOptions) : Values
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| options | com.mongodb.client.model.FindOneAndDeleteOptions |
Return
( Values )
findOneAndReplace
findOneAndReplace(filter: org.bson.conversions.Bson, data: Values) : Values
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| data | Values |
Return
( Values )
findOneAndReplace(filter: org.bson.conversions.Bson, data: Values, options: com.mongodb.client.model.FindOneAndReplaceOptions) : Values
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| data | Values | |
| options | com.mongodb.client.model.FindOneAndReplaceOptions |
Return
( Values )
findOneAndUpdate
findOneAndUpdate(filter: org.bson.conversions.Bson, update: java.util.List<?>) : Values
Description
Atomically find a document and update it.
How To Use
const setUpdate = _mongo.updates().set('quantity', 42);
const renameUpdate = _mongo.updates().rename('other', 'more');
const updateList = _val.list();
updateList.add(setUpdate);
updateList.add(renameUpdate);
const combinedUpdates = _mongo.updates().combine(updateList);
c.findOneAndUpdate(
_mongo.filters().eq('name', 'Abc'),
combinedUpdates
);
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | A document describing the query filter, which may not be null. |
| update | java.util.List | A pipeline describing the update, which may not be null. |
Return
( Values )
The document that was updated before the update was applied. If no documents matched the query filter, then null will be returned.
findOneAndUpdate(filter: org.bson.conversions.Bson, update: java.util.List<?>, options: com.mongodb.client.model.FindOneAndUpdateOptions) : Values
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| update | java.util.List | |
| options | com.mongodb.client.model.FindOneAndUpdateOptions |
Return
( Values )
findOneAndUpdate(filter: org.bson.conversions.Bson, update: org.bson.conversions.Bson) : Values
Description
Atomically find a document and update it.
How To Use
const setUpdate = _mongo.updates().set('quantity', 42);
const renameUpdate = _mongo.updates().rename('other', 'more');
const updateList = _val.list();
updateList.add(setUpdate);
updateList.add(renameUpdate);
const combinedUpdates = _mongo.updates().combine(updateList);
c.findOneAndUpdate(
_mongo.filters().eq('name', 'Abc'),
combinedUpdates
);
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | A document describing the query filter, which may not be null. |
| update | org.bson.conversions.Bson | A pipeline describing the update, which may not be null. |
Return
( Values )
The document that was updated before the update was applied. If no documents matched the query filter, then null will be returned.
findOneAndUpdate(filter: org.bson.conversions.Bson, update: org.bson.conversions.Bson, options: com.mongodb.client.model.FindOneAndUpdateOptions) : Values
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| update | org.bson.conversions.Bson | |
| options | com.mongodb.client.model.FindOneAndUpdateOptions |
Return
( Values )
insertMany
insertMany(data: Values) : java.util.List<string>
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| data | Values |
Return
( java.util.List )
insertMany(data: Values, options: com.mongodb.client.model.InsertManyOptions) : java.util.List<string>
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| data | Values | |
| options | com.mongodb.client.model.InsertManyOptions |
Return
( java.util.List )
insertOne
insertOne(data: Values) : string
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| data | Values |
Return
( string )
insertOne(data: Values, options: com.mongodb.client.model.InsertOneOptions) : string
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| data | Values | |
| options | com.mongodb.client.model.InsertOneOptions |
Return
( string )
renameCollection
renameCollection(fullName: string) : void
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| fullName | string |
Return
( void )
renameCollection(databaseName: string, collectionName: string) : void
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| databaseName | string | |
| collectionName | string |
Return
( void )
replaceOne
replaceOne(filter: org.bson.conversions.Bson, data: Values) : long
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| data | Values |
Return
( long )
replaceOne(filter: org.bson.conversions.Bson, data: Values, options: com.mongodb.client.model.ReplaceOptions) : long
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| data | Values | |
| options | com.mongodb.client.model.ReplaceOptions |
Return
( long )
updateMany
updateMany(filter: org.bson.conversions.Bson, update: java.util.List<?>) : long
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| update | java.util.List |
Return
( long )
updateMany(filter: org.bson.conversions.Bson, update: java.util.List<?>, options: com.mongodb.client.model.UpdateOptions) : long
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| update | java.util.List | |
| options | com.mongodb.client.model.UpdateOptions |
Return
( long )
updateMany(filter: org.bson.conversions.Bson, update: org.bson.conversions.Bson) : long
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| update | org.bson.conversions.Bson |
Return
( long )
updateMany(filter: org.bson.conversions.Bson, update: org.bson.conversions.Bson, options: com.mongodb.client.model.UpdateOptions) : long
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | |
| update | org.bson.conversions.Bson | |
| options | com.mongodb.client.model.UpdateOptions |
Return
( long )
updateOne
updateOne(filter: org.bson.conversions.Bson, update: java.util.List<?>) : long
Description
Update a single document in the collection according to the specified arguments.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | A document describing the query filter, which may not be null. |
| update | java.util.List | A pipeline describing the update, which may not be null. |
Return
( long )
The result of the update one operation.
updateOne(filter: org.bson.conversions.Bson, update: java.util.List<?>, options: com.mongodb.client.model.UpdateOptions) : long
Description
Update a single document in the collection according to the specified arguments.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | A document describing the query filter, which may not be null. |
| update | java.util.List | A pipeline describing the update, which may not be null. |
| options | com.mongodb.client.model.UpdateOptions | The options to apply to the update operation. |
Return
( long )
The result of the update one operation.
updateOne(filter: org.bson.conversions.Bson, update: org.bson.conversions.Bson) : long
Description
Update a single document in the collection according to the specified arguments.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | A document describing the query filter, which may not be null. |
| update | org.bson.conversions.Bson | A document describing the update, which may not be null. The update to apply must include at least one update operator. |
Return
( long )
The result of the update one operation.
updateOne(filter: org.bson.conversions.Bson, update: org.bson.conversions.Bson, options: com.mongodb.client.model.UpdateOptions) : long
Description
Update a single document in the collection according to the specified arguments.
Attributes
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| filter | org.bson.conversions.Bson | A document describing the query filter, which may not be null. |
| update | org.bson.conversions.Bson | A document describing the update, which may not be null. The update to apply must include at least one update operator. |
| options | com.mongodb.client.model.UpdateOptions | The options to apply to the update operation. |
Return
( long )
The result of the update one operation.