MongoDB backend


#1

Does anyone know if there is a way to hook up a MongoDB Database to a test? I see in the Data Files that I can add a data base, but this seems to only be SQL based.

I’m going to try to do it through script in the editor, but just wanted to know if there was some built in way to do it first.

Thanks!


#2

No way that I figured out. I just linked the mongoDB Java driver to the test and everything works just fine


#3

Hi Will York,
i am starting to read and write to Mongo. Currently i am using SQL db and working fine but i am new on connecting to Mongdb. In here, you seems to have succeeded in doing so, could i request for details on whats needed to coded ? i am using groovy… TIA


#4

the tricky bit with mongo is how to find documents that have UUID in them…ive posted how ive manage to do it here


#5

@ChewJin Koh

install the mongodb driver and connect to the mongo db through that…something like this

import com.mongodb.client.MongoCursor

import com.mongodb.MongoClient

import com.mongodb.BasicDBObject

import com.mongodb.DBObject

import com.mongodb.DBCursor

import com.mongodb.MongoCredential as MongoCredential

import com.mongodb.client.MongoCollection

import com.mongodb.client.MongoDatabase

import com.mongodb.MongoClientURI

import com.mongodb.client.result.DeleteResult

import com.mongodb.client.FindIterable

public class dataBaseMethods {

public static Connection connection

public static MongoDatabase db

public static MongoClient mongoClient

@Keyword

def mongoInitialize(String strConnectionString,String Database,String firstCollection){

mongoClient = null

String ClientURI = strConnectionString

MongoClientURI uri = new MongoClientURI(ClientURI)

mongoClient = new MongoClient(uri
db = mongoClient.getDatabase(Database)
MongoIterable collections = db.listCollectionNames()
}