public class MongoDbClient extends Object
Constructor and Description |
---|
MongoDbClient(String url,
String collectionName)
The MongoDbClient constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all resources associated with this instance.
|
org.bson.Document |
find(org.bson.conversions.Bson filter)
Finds a single document in the collection according to the specified arguments.
|
void |
insert(List<org.bson.Document> documents,
boolean ordered)
Inserts one or more documents.
|
void |
update(org.bson.conversions.Bson filter,
org.bson.conversions.Bson document,
boolean upsert,
boolean many)
Update a single or all documents in the collection according to the specified arguments.
|
public void insert(List<org.bson.Document> documents, boolean ordered)
Inserts one or more documents. This method is equivalent to a call to the bulkWrite method. The documents will be inserted in the order provided, stopping on the first failed insertion.
documents
- documentspublic void update(org.bson.conversions.Bson filter, org.bson.conversions.Bson document, boolean upsert, boolean many)
Update a single or all documents in the collection according to the specified arguments. When upsert set to true, the new document will be inserted if there are no matches to the query filter.
filter
- Bson filterdocument
- Bson documentupsert
- a new document should be inserted if there are no matches to the query filtermany
- whether find all documents according to the query filterpublic org.bson.Document find(org.bson.conversions.Bson filter)
Finds a single document in the collection according to the specified arguments.
filter
- Bson filterpublic void close()
Closes all resources associated with this instance.
Copyright © 2022 The Apache Software Foundation. All rights reserved.