public class MongoDBConnectionHelper extends Object
Modifier and Type | Method and Description |
---|---|
static com.mongodb.client.MongoCollection<org.bson.Document> |
getCollection(com.mongodb.MongoClient mongoClient,
String dbname,
String collection)
Retrieve a collection from the MongoDB server
|
static com.mongodb.client.MongoDatabase |
getDatabase(com.mongodb.MongoClient mongoClient,
String dbname) |
static boolean |
hasCollection(com.mongodb.MongoClient mongoClient,
String dbname,
String collection)
Check if the collection exists and if it is not empty
|
static com.mongodb.MongoClient |
newMongoClient(String server)
Initialize a connection to the MongoDB server
|
public static com.mongodb.MongoClient newMongoClient(String server)
server
- the server urlpublic static com.mongodb.client.MongoDatabase getDatabase(com.mongodb.MongoClient mongoClient, String dbname)
public static com.mongodb.client.MongoCollection<org.bson.Document> getCollection(com.mongodb.MongoClient mongoClient, String dbname, String collection)
public static boolean hasCollection(com.mongodb.MongoClient mongoClient, String dbname, String collection)
mongoClient
- the Mongo clientdbname
- the database namecollection
- the collection nameCopyright © 2017 Nuxeo. All rights reserved.