kmularise commented on code in PR #4987:
URL: https://github.com/apache/zeppelin/pull/4987#discussion_r2233858331
##########
mongodb/src/main/resources/shell_extension.js:
##########
@@ -104,6 +104,26 @@ function printTable(dbquery, fields, flattenArray) {
printTable(this, fields, flattenArray);
};
+function ensureTableFunction() {
+ var tableFunc = function(fields, flattenArray) {
+ printTable(this, fields, flattenArray);
+ return this;
+ };
+
+ try {
+ var sampleCursor = db.getCollection('__dummy__').find({}).limit(0);
+ var proto = Object.getPrototypeOf(sampleCursor);
+
+ if (proto && !proto.table) {
+ proto.table = tableFunc;
+ }
+ } catch (e) {
+ print("Registration Error: prototype registration failed:", e.message);
+ }
+}
Review Comment:
I think you're right to avoid duplication. Looking at this again, there's
potential for duplicate registration, and merging into `ensureTableFunction`
makes more sense. I'll move the existing table prototype logic into
`ensureTableFunction`.
Thanks for the feedback!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]