public class MongoClientImpl extends Object implements MongoClient
Constructor and Description |
---|
MongoClientImpl(com.mongodb.MongoClient mongo,
String database) |
Modifier and Type | Method and Description |
---|---|
org.bson.Document |
addUser(String username,
String password) |
void |
close() |
long |
countObjects(String collection,
org.bson.conversions.Bson query) |
void |
createCollection(String collection,
boolean capped,
Integer maxObjects,
Integer size) |
com.mongodb.client.gridfs.model.GridFSFile |
createFile(InputStream content,
String filename,
org.bson.Document metadata) |
void |
createIndex(String collection,
String field,
IndexOrder order) |
void |
dropCollection(String collection) |
void |
dropDatabase() |
void |
dropIndex(String collection,
String name) |
org.bson.Document |
executeCommand(org.bson.Document command) |
boolean |
existDatabase(String name) |
boolean |
existsCollection(String collection) |
org.bson.Document |
findAndUpdateObject(String collection,
org.bson.Document query,
org.bson.Document update,
List<String> fields,
boolean returnNew,
org.bson.Document sortBy,
boolean remove,
boolean upsert,
boolean bypassDocumentValidation,
boolean returnId) |
Iterable<com.mongodb.client.gridfs.model.GridFSFile> |
findFiles(org.bson.Document query) |
Iterable<org.bson.Document> |
findObjects(String collection,
org.bson.Document query,
List<String> fields,
Integer numToSkip,
Integer limit,
org.bson.Document sortBy) |
Iterable<org.bson.Document> |
findObjects(String collection,
org.bson.Document query,
List<String> fields,
Integer numToSkip,
Integer limit,
org.bson.Document sortBy,
boolean returnId) |
com.mongodb.client.gridfs.model.GridFSFile |
findOneFile(org.bson.Document query) |
org.bson.Document |
findOneObject(String collection,
org.bson.Document query,
List<String> fields,
boolean failOnNotFound,
boolean returnId) |
com.mongodb.client.MongoCollection<org.bson.Document> |
getCollection(String collection) |
String |
getConnectionId() |
com.mongodb.client.MongoDatabase |
getDatabase(String databaseName) |
InputStream |
getFileContent(org.bson.types.ObjectId id) |
protected com.mongodb.client.gridfs.GridFSBucket |
getGridFs() |
String |
insertObject(String collection,
org.bson.Document document) |
org.bson.Document |
insertObjects(String collection,
List<org.bson.Document> documents,
boolean ordered) |
boolean |
isAlive() |
Iterable<String> |
listCollections() |
Iterable<com.mongodb.client.gridfs.model.GridFSFile> |
listFiles(org.bson.Document query) |
Collection<org.bson.Document> |
listIndices(String collection) |
Iterable<org.bson.Document> |
mapReduceObjects(String collection,
String mapFunction,
String reduceFunction,
String outputCollection) |
void |
removeFiles(org.bson.BsonObjectId id) |
void |
removeObjects(String collection,
org.bson.conversions.Bson query) |
void |
saveObject(String collectionName,
org.bson.Document document) |
org.bson.Document |
updateObjects(String collection,
org.bson.Document query,
org.bson.Document document,
boolean multi,
boolean upsert) |
public MongoClientImpl(com.mongodb.MongoClient mongo, String database)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public com.mongodb.client.MongoDatabase getDatabase(String databaseName)
getDatabase
in interface MongoClient
public boolean existDatabase(String name)
existDatabase
in interface MongoClient
public long countObjects(@NotNull String collection, org.bson.conversions.Bson query)
countObjects
in interface MongoClient
public void createCollection(@NotNull String collection, boolean capped, Integer maxObjects, Integer size)
createCollection
in interface MongoClient
public com.mongodb.client.MongoCollection<org.bson.Document> getCollection(@NotNull String collection)
getCollection
in interface MongoClient
public org.bson.Document addUser(String username, String password)
addUser
in interface MongoClient
public void dropDatabase()
dropDatabase
in interface MongoClient
public void dropCollection(@NotNull String collection)
dropCollection
in interface MongoClient
public boolean existsCollection(@NotNull String collection)
existsCollection
in interface MongoClient
public Iterable<org.bson.Document> findObjects(@NotNull String collection, @NotNull org.bson.Document query, List<String> fields, Integer numToSkip, Integer limit, org.bson.Document sortBy)
findObjects
in interface MongoClient
public Iterable<org.bson.Document> findObjects(@NotNull String collection, @NotNull org.bson.Document query, List<String> fields, Integer numToSkip, Integer limit, org.bson.Document sortBy, boolean returnId)
findObjects
in interface MongoClient
public org.bson.Document findOneObject(@NotNull String collection, @NotNull org.bson.Document query, List<String> fields, boolean failOnNotFound, boolean returnId)
findOneObject
in interface MongoClient
public String insertObject(@NotNull String collection, @NotNull org.bson.Document document)
insertObject
in interface MongoClient
public org.bson.Document insertObjects(String collection, List<org.bson.Document> documents, boolean ordered)
insertObjects
in interface MongoClient
public Iterable<String> listCollections()
listCollections
in interface MongoClient
public Iterable<org.bson.Document> mapReduceObjects(@NotNull String collection, @NotNull String mapFunction, @NotNull String reduceFunction, String outputCollection)
mapReduceObjects
in interface MongoClient
public void removeObjects(@NotNull String collection, @NotNull org.bson.conversions.Bson query)
removeObjects
in interface MongoClient
public void saveObject(@NotNull String collectionName, @NotNull org.bson.Document document)
saveObject
in interface MongoClient
public org.bson.Document updateObjects(@NotNull String collection, @NotNull org.bson.Document query, org.bson.Document document, boolean multi, boolean upsert)
updateObjects
in interface MongoClient
public void createIndex(String collection, String field, IndexOrder order)
createIndex
in interface MongoClient
public void dropIndex(String collection, String name)
dropIndex
in interface MongoClient
public Collection<org.bson.Document> listIndices(String collection)
listIndices
in interface MongoClient
public com.mongodb.client.gridfs.model.GridFSFile createFile(@NotNull InputStream content, @NotNull String filename, org.bson.Document metadata)
createFile
in interface MongoClient
public Iterable<com.mongodb.client.gridfs.model.GridFSFile> findFiles(@NotNull org.bson.Document query)
findFiles
in interface MongoClient
public com.mongodb.client.gridfs.model.GridFSFile findOneFile(@NotNull org.bson.Document query)
findOneFile
in interface MongoClient
public org.bson.Document findAndUpdateObject(@NotNull String collection, @NotNull org.bson.Document query, @NotNull org.bson.Document update, List<String> fields, boolean returnNew, org.bson.Document sortBy, boolean remove, boolean upsert, boolean bypassDocumentValidation, boolean returnId)
findAndUpdateObject
in interface MongoClient
public InputStream getFileContent(@NotNull org.bson.types.ObjectId id)
getFileContent
in interface MongoClient
public Iterable<com.mongodb.client.gridfs.model.GridFSFile> listFiles(org.bson.Document query)
listFiles
in interface MongoClient
public void removeFiles(org.bson.BsonObjectId id)
removeFiles
in interface MongoClient
public org.bson.Document executeCommand(org.bson.Document command)
executeCommand
in interface MongoClient
protected com.mongodb.client.gridfs.GridFSBucket getGridFs()
public boolean isAlive()
isAlive
in interface MongoClient
public String getConnectionId()
getConnectionId
in interface MongoClient
Copyright © 2010–2019. All rights reserved.