Skip to content

Commit

Permalink
Update collection.js
Browse files Browse the repository at this point in the history
Solve Error : TypeError: Cannot read properties of undefined (reading 'split')
  • Loading branch information
vevedh authored Feb 6, 2024
1 parent b08bee7 commit bf30dbd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit bf30dbd

Please sign in to comment.