File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
packages/collection-model/lib Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -239,17 +239,22 @@ const CollectionModel = AmpersandModel.extend(debounceActions(['fetch']), {
239239 if ( ! shouldFetch ( this . status , force ) ) {
240240 return ;
241241 }
242+ // When trying to fetch collectionStats for a namespace whose db does not exist,
243+ // the server throws an error. This happens because we show dbs/collections to
244+ // the user from their roles/privileges. So, if the database does not exist, we
245+ // skip fetching collectionStats for the namespace.
246+ const dbExists = ! getParentByType ( this , 'Database' ) . is_non_existant ;
242247 try {
243248 const newStatus = this . status === 'initial' ? 'fetching' : 'refreshing' ;
244249 this . set ( { status : newStatus } ) ;
245250 const [ collStats , collectionInfo ] = await Promise . all ( [
246- dataService . collectionStats ( this . database , this . name ) ,
251+ dbExists ? dataService . collectionStats ( this . database , this . name ) : null ,
247252 fetchInfo ? dataService . collectionInfo ( this . database , this . name ) : null ,
248253 ] ) ;
249254 this . set ( {
250255 status : 'ready' ,
251256 statusError : null ,
252- ...collStats ,
257+ ...( collStats && collStats ) ,
253258 ...( collectionInfo && pickCollectionInfo ( collectionInfo ) ) ,
254259 } ) ;
255260 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments