Search code examples
node.jscouchbasefaker

Close Couchbase connection once entries have been saved


I use Faker to insert some dummy data into Couchbase database. It seems to me that I need to close the connection on the insertion operations complete because now when it inserts all the entries, the app keeps being active, doesn't return me to console. How to manage it?


Solution

  • To close connection to bucket you can use bucket.shutdown() function. See example below:

    couchbase.connect(config, function(err, bucket) {
      ... // do some work
      bucket.shutdown(); // shutdown connection on work done
    });
    

    Link to test for this function on github.