couldn't use mongo db drivers
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
[Hall of Fame]
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks everyone for the help!
@msalvador, I'm happy to hear that you've found the solution 🙂 . Thanks for sharing it with us.
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes external function
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
