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