Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9150483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:37:01+00:00 2026-06-17T11:37:01+00:00

Currently you can find out that a view doesn’t exists when you try to

  • 0

Currently you can find out that a view doesn’t exists when you try to perform a query after attempting to retrieve the view:

var result = _couchClient.GetView<etc>("DocumentName", "ViewNameThatDoesNotExist");
result.Count(); // This returns a service exception

You find out it doesn’t exist after Count throws an exception, so at the moment I use a try/catch to determine if there is an exception.

Is there a more elegant solution that doesn’t require as many resources as performing a query?
There doesn’t seem to be anything like

result.exists()

or something similar.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:37:02+00:00Added an answer on June 17, 2026 at 11:37 am

    Matt – thanks for sharing your extension method! Having seen this question pop up a couple of times now, I’m baking support into the 1.2.1 client (to be released on Feb 05, 2013). The answer that follows isn’t valid in 1.2.0, but is a preview for future reference. I’m also including it as an answer instead of a comment for better code highlighting…

    In 1.2.1, there will be two ways to check for a view not existing. The first is to use the view’s new CheckExists() method. This method will query the design document and parse the JSON. Similar to Matt’s approach, but doesn’t use the CouchbaseCluster API.

    var view = client.GetView("designDoc", "viewName")
    
    if (view.CheckExists())
    {
      view.Count();
    }
    

    The second approach is to catch the exception, which is meaningfully typed (no longer an InvalidOperationException). The advantage of this approach is one fewer HTTP query.

    var view = client.GetView("designDoc", "viewName")
    
    try {
        view.Count();
    } catch (ViewNotFoundException vnfe) { //extends ViewException
        ...
    } catch (ViewException ve) { //bad params for example
       log.Error("Error {0}, Reason {1}", ve.Error, ve.Reason);
    } catch (Exception e) {
       ...
    }
    

    The Jira request is at http://www.couchbase.com/issues/browse/NCBC-165 and the code is in review at http://review.couchbase.org/#/c/24068/1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I find out the currently logged on user then create a text
How can I find out what the current charset is in C++? In a
Using my c++ program how can I find out what group the current user
Maybe I'm not searching correctly, but I can't find out how to configure the
I can't seem to get all the table names that a view is trying
I can't find anything around for current versions around, but my issue is exactly
How can I find the current page number in jqGrid (using jQuery of course).
In C# how can i find the week of the current date, i am
Using Git, how can you find the difference between the current and the last
Currently I can set ringtones and notifications with: byte[] buffer = null; InputStream fIn

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.