cancel
Showing results for 
Search instead for 
Did you mean: 

couldn't use mongo db drivers

SOLVED
Highlighted
Contributor

couldn't use mongo db drivers

Hi,
I downloaded both async and sync drivers from here https://mongodb.github.io/mongo-java-driver/3.12/driver-async/getting-started/installation/

I import my drivers in classpath(current project), I set java VM.

I use this code, but I couldn't see any obyect.


async function main() {
var MongoClient = require('mongodb')
var client = await MongoClient.connect('mongodb://string<1>:<string2>:10255/?ssl=true&appName=@user@')
var db = client.db('dlc-dev-cosmos')
var collection = db.collection('batteries')

var docs = await collection.find({}).limit(5).toArray()
//console.log(docs)
Log.Message(docs)
await client.close()
}

main();


Could help me

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Re: couldn't use mongo db drivers

MongoDB is a father root that contains all the libraries, in the javascript files, there is this call Require(.\<folder1>\<folder2>\xxx.js), and as I can see this not work importing in my project.

I schift to another solution... java libraries, so I imported them in java bridge panel and use them.

View solution in original post

8 REPLIES 8
Community Leader

Re: couldn't use mongo db drivers

If I understand you correctly, you are trying to get Java methods from the mongoDB driver, right?

 

The internal example you are referring to:

 

var MongoClient = require('mongodb')

 

What's in the Mongodb file?

 

Did you do it together with this manual?

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calli...

Highlighted
Community Manager

Re: couldn't use mongo db drivers

Hi @msalvador,

 

Could you please clarify what you mean by "I couldn't see any object"? Where don't you see objects? If you are talking about Code Completion, I'm not sure if TestComplete shows objects from external libraries.

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

 Join the 2020 API Masterminds event in the ReadyAPI Community to demonstrate your excellent expertise, help people and win prizes! Start participating today!
Highlighted
Contributor

Re: couldn't use mongo db drivers

Hi tanya,

What I wrote in my first post is not correct, now I clarify the situation.

I download with this command: npm i –save mongodb     the mongo bd libraries(find in attachment, node_modules.zip).

This libraries in filesystem have a tree structure.

Then I run the function you find in the firt post, but it doesn't work.

I tried to import libreries in my project but have a tree structure and don't work.

I post a picture about my project explore

I think you need some more infos, so please reply me

Highlighted
Community Hero

Re: couldn't use mongo db drivers

If Mongdb is a javascript file, you need to actually add it to the project.  In your tree structure, I don't see it anywhere so calling requires("mongodb") won't work.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Contributor

Re: couldn't use mongo db drivers

MongoDB is a father root that contains all the libraries, in the javascript files, there is this call Require(.\<folder1>\<folder2>\xxx.js), and as I can see this not work importing in my project.

I schift to another solution... java libraries, so I imported them in java bridge panel and use them.

View solution in original post

Highlighted
Community Manager

Re: couldn't use mongo db drivers

Thanks everyone for the help!

 

@msalvador, I'm happy to hear that you've found the solution Smiley Happy . Thanks for sharing it with us.

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

 Join the 2020 API Masterminds event in the ReadyAPI Community to demonstrate your excellent expertise, help people and win prizes! Start participating today!
Highlighted
Contributor

Re: couldn't use mongo db drivers

yes external function

Highlighted
Contributor

Re: couldn't use ODBC mongo db drivers

Hi Tanya,

in attachment the picture of external libraries imported and a snippet.