Skip to main content

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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonThe 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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonThe query filter.
optionscom.mongodb.client.model.CountOptionsThe options describing the count.
Return

( long )

The number of documents in the collection.


createIndex


createIndex(keys: org.bson.conversions.Bson) : string

Attributes
NAMETYPEDESCRIPTION
keysorg.bson.conversions.Bson
Return

( string )


deleteMany


deleteMany(filter: org.bson.conversions.Bson) : void

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
Return

( void )


deleteMany(filter: org.bson.conversions.Bson, options: com.mongodb.client.model.DeleteOptions) : void

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
optionscom.mongodb.client.model.DeleteOptions
Return

( void )


deleteOne


deleteOne(filter: org.bson.conversions.Bson) : void

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
Return

( void )


deleteOne(filter: org.bson.conversions.Bson, options: com.mongodb.client.model.DeleteOptions) : void

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
optionscom.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
NAMETYPEDESCRIPTION
optionscom.mongodb.client.model.DropCollectionOptionsVarious 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
NAMETYPEDESCRIPTION
optionscom.mongodb.client.model.EstimatedDocumentCountOptionsThe options describing the count.
Return

( long )

The number of documents in the collection.


find


find() : MongoFindIterable

Description

Finds all documents in the collection.

Return

( MongoFindIterable )

The find iterable interface.


find(filter: org.bson.conversions.Bson) : MongoFindIterable

Description

Finds all documents in the collection.

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonThe query filter.
Return

( MongoFindIterable )

The find iterable interface.


findOneAndDelete


findOneAndDelete(filter: org.bson.conversions.Bson) : Values

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
Return

( Values )


findOneAndDelete(filter: org.bson.conversions.Bson, options: com.mongodb.client.model.FindOneAndDeleteOptions) : Values

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
optionscom.mongodb.client.model.FindOneAndDeleteOptions
Return

( Values )


findOneAndReplace


findOneAndReplace(filter: org.bson.conversions.Bson, data: Values) : Values

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
dataValues
Return

( Values )


findOneAndReplace(filter: org.bson.conversions.Bson, data: Values, options: com.mongodb.client.model.FindOneAndReplaceOptions) : Values

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
dataValues
optionscom.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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonA document describing the query filter, which may not be null.
updatejava.util.ListA 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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
updatejava.util.List
optionscom.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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonA document describing the query filter, which may not be null.
updateorg.bson.conversions.BsonA 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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
updateorg.bson.conversions.Bson
optionscom.mongodb.client.model.FindOneAndUpdateOptions
Return

( Values )


insertMany


insertMany(data: Values) : java.util.List<string>

Attributes
NAMETYPEDESCRIPTION
dataValues
Return

( java.util.List )


insertMany(data: Values, options: com.mongodb.client.model.InsertManyOptions) : java.util.List<string>

Attributes
NAMETYPEDESCRIPTION
dataValues
optionscom.mongodb.client.model.InsertManyOptions
Return

( java.util.List )


insertOne


insertOne(data: Values) : string

Attributes
NAMETYPEDESCRIPTION
dataValues
Return

( string )


insertOne(data: Values, options: com.mongodb.client.model.InsertOneOptions) : string

Attributes
NAMETYPEDESCRIPTION
dataValues
optionscom.mongodb.client.model.InsertOneOptions
Return

( string )


renameCollection


renameCollection(fullName: string) : void

Attributes
NAMETYPEDESCRIPTION
fullNamestring
Return

( void )


renameCollection(databaseName: string, collectionName: string) : void

Attributes
NAMETYPEDESCRIPTION
databaseNamestring
collectionNamestring
Return

( void )


replaceOne


replaceOne(filter: org.bson.conversions.Bson, data: Values) : long

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
dataValues
Return

( long )


replaceOne(filter: org.bson.conversions.Bson, data: Values, options: com.mongodb.client.model.ReplaceOptions) : long

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
dataValues
optionscom.mongodb.client.model.ReplaceOptions
Return

( long )


updateMany


updateMany(filter: org.bson.conversions.Bson, update: java.util.List<?>) : long

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
updatejava.util.List
Return

( long )


updateMany(filter: org.bson.conversions.Bson, update: java.util.List<?>, options: com.mongodb.client.model.UpdateOptions) : long

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
updatejava.util.List
optionscom.mongodb.client.model.UpdateOptions
Return

( long )


updateMany(filter: org.bson.conversions.Bson, update: org.bson.conversions.Bson) : long

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
updateorg.bson.conversions.Bson
Return

( long )


updateMany(filter: org.bson.conversions.Bson, update: org.bson.conversions.Bson, options: com.mongodb.client.model.UpdateOptions) : long

Attributes
NAMETYPEDESCRIPTION
filterorg.bson.conversions.Bson
updateorg.bson.conversions.Bson
optionscom.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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonA document describing the query filter, which may not be null.
updatejava.util.ListA 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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonA document describing the query filter, which may not be null.
updatejava.util.ListA pipeline describing the update, which may not be null.
optionscom.mongodb.client.model.UpdateOptionsThe 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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonA document describing the query filter, which may not be null.
updateorg.bson.conversions.BsonA 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
NAMETYPEDESCRIPTION
filterorg.bson.conversions.BsonA document describing the query filter, which may not be null.
updateorg.bson.conversions.BsonA document describing the update, which may not be null. The update to apply must include at least one update operator.
optionscom.mongodb.client.model.UpdateOptionsThe options to apply to the update operation.
Return

( long )

The result of the update one operation.