MongoDB functions with print to console
Answered
I have been very pleased with the DataGrip interface to MongoDB. I plan to use it for my Irtro to Database systems class.
I have found a problem I can't seem to resolve.
The following code snippet assigns a mongodb cursor to a variable and then attempts to loop through print pieces to the console.
The code executes successfully (no errors), but there is no console display. Is there a setting or missing console window that I haven't exposed to make this work. In the Mongodb shell it works as expected, displaying the fields from the matching documents.
var cursor1 = db.course.find();
cursor1.forEach(function(x) { print(x.courseCd); });
if I enter cursor1 and execute it, it does display the correct items in the cursor.
So I am pretty certain it is the display that is not working.
Thanks,
Roland DePratti
Univ of Richmond
Please sign in to leave a comment.
Hello Rdepratt,
You are right, print function is currently now supported in DataGrip.
DataGrip displays value of evaluated statement. forEach function does not return result therefore you don't see anything.
A workaround is to append values to a list and then evaluate the list:
It's possible to implement print function. I'll try to fix this problem next week. Once it's fixed you'll need to only update driver, no need to wait for IDE update.
Here is an issue for this:
https://youtrack.jetbrains.com/issue/DBE-10998