1

when we get documents from couchbase server using select query not documents which i added manually only programatically added record return(using cluster in c# i added in couchbase server) but i want all the documents

my code below . what i am missing

        var clientConfiguration = new ClientConfiguration();
        clientConfiguration.Servers = new List<Uri> { new Uri("http://localhost:8091/pools/") };

        List<string> objDocList = new List<string>();
        Cluster Cluster = new Cluster(clientConfiguration);
        var bucket = Cluster.OpenBucket();
        var result = bucket.Query<dynamic>("select * from testbucket");


        foreach (var row in result)
        {

                dynamic propJSON = JsonConvert.SerializeObject(row);

       //propJSON not contain id

        }
borrrden
  • 33,256
  • 8
  • 74
  • 109

1 Answers1

0

As written your query is hitting the default bucket, not the testbucket. You should also wrap your bucket in a using statement.

You'll likely need to create a primary index on your testbucket. This answer gives the best discussion of what's necessary.

Your code will end up being something like...

using (var bucket = Cluster.OpenBucket("TestCheck2"))
{
    var query = bucket.CreateQuery("dev_testcheck2", "getall");
    var data = bucket.Query<dynamic>(query);
    foreach (var item in data.Rows)
    {
        Console.WriteLine($"{item.Value[0]}: Title: \"{item.Value[1]}\" Body: {item.Value[2]}");
    }
}

dev_testcheck2 is the suffix of the name of my development view design document and getall is the name of my view.

azarc3
  • 1,277
  • 13
  • 21