jstests/libs/override_methods/inject_tenant_prefix.js
/**
 * Removes a tenant prefix from all the database name and namespace fields in the provided object,
 * where applicable.
 */
Removes a tenant prefix from all the database name and namespace fields in the provided object,
where applicable.
Removes a tenant prefix from all the database name and namespace fields in the provided object where applicable .
function removeTenantId(obj) {
    for (let k of Object.keys(obj)) {
        let v = obj[k];
        let originalK = removeTenantIdFromString(k);
        if (typeof v === "string") {
            if (k === "dbName" || k == "db" || k == "dropped") {
                obj[originalK] = extractOriginalDbName(v);
            } else if (k === "namespace" || k === "ns") {
                obj[originalK] = extractOriginalNs(v);
            } else if (k === "errmsg" || k == "name") {
                obj[originalK] = removeTenantIdFromString(v);
            }
        } else if (Array.isArray(v)) {
            obj[originalK] = v.map((item) => {
                return (typeof item === "object" && item !== null) ? removeTenantId(item) : item;
            });
        } else if (typeof v === "object" && v !== null && Object.keys(v).length > 0) {
            obj[originalK] = removeTenantId(v);
        }
    }
    return obj;
}
function removeTenantId ( obj ) { for ( let k of Object . keys ( obj ) ) { let v = obj [ k ] ; let originalK = removeTenantIdFromString ( k ) ; if ( typeof v === "string" ) { if ( k === "dbName" || k == "db" || k == "dropped" ) { obj [ originalK ] = extractOriginalDbName ( v ) ; } else if ( k === "namespace" || k === "ns" ) { obj [ originalK ] = extractOriginalNs ( v ) ; } else if ( k === "errmsg" || k == "name" ) { obj [ originalK ] = removeTenantIdFromString ( v ) ; } } else if ( Array . isArray ( v ) ) { obj [ originalK ] = v . map ( ( item ) => { return ( typeof item === "object" && item !== null ) ? removeTenantId ( item ) : item ; } ) ; } else if ( typeof v === "object" && v !== null && Object . keys ( v ) . length > 0 ) { obj [ originalK ] = removeTenantId ( v ) ; } } return obj ; }
Removes a tenant prefix from all the database name and namespace fields in the provided object,
 where applicable.
Removes a tenant prefix from all the database name and namespace fields in the provided object where applicable .