couchbase - Checking for document exists in DB in couchbase - couchbase tutorial - couchbase lite




Checking for document exists in DB

Here is a program to check for document exists in DB in couchbase

String bucketName = "bucket";
List<String> nodes = Arrays.asList("node1","node2"); // IP or hostname of one or more nodes in the cluster

Cluster cluster = CouchbaseCluster.create(nodes);
Bucket bucket = cluster.openBucket(bucketName);

//check for a document by its ID

String id="bucket_collection_user_123456";//document id
boolean exists=bucket.exists(id);
if(exists){
  System.out.println("Document exists");
} 
bucket.close();
cluster.disconnect();


Related Searches to Checking for document exists in DB in couchbase