diff --git a/lib/collection.js b/lib/collection.js index 599a944..d8fe13f 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -14,11 +14,17 @@ class CollectionService extends Service { // Helper function to process stats object processObjectInfos (infos) { // In Mongo the collection name key is ns and prefixed by the db name, change to the more intuitive name just as in create - const namespace = infos.ns.split('.'); - if (namespace.length > 1) { - infos.name = namespace[1]; + if (Object(infos).hasOwnProperty('ns')) { + const namespace = infos.ns?.split('.'); + if (namespace?.length > 1) { + infos.name = namespace[1]; + } + delete infos.ns; } - delete infos.ns; + if (infos.s.namespace.collection) { + infos.name = infos.s.namespace.collection + } + return infos; }