How to retrieve a list of keys/documents in couchbase database in C#

后端 未结 5 1236
说谎
说谎 2021-01-01 02:01

I\'m totally new to couchbase.

This is the sample code I use for insert and get documents:

using (var bucket = Cluster.OpenBucket())
{
    var docume         


        
5条回答
  •  执念已碎
    2021-01-01 02:37

    Please note that N1QL is a query language and needs to work along with views in order to scan and retrieve all the keys from couchbase server. N1QL allows you to create a primary index on your dataset (using views) and then use that index to run your queries.

    After you install and setup N1QL the following example query will create a view index/primary index on the couchbase server

    Create primary index on bucket;

    Once the index is created then you can retrieve all the keys from the server.

    *select * from bucket;

    Internally the query engine will use the view/primary index to fetch a list of keys of the server (full bucket scan) and then use that list to retrieve the values.

提交回复
热议问题