Search code examples
c#couchbasecouchbase-viewcouchbase-sync-gateway

couchbase server not return id within record using c# code


when we get records from couchbase server using select query not get id of each record

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

        }

I want id for updating record


Solution

  • You need to use the meta function to return the id

    select meta(tb).id, tb.* from testbucket tb