Connect to Cloudant CouchDB with Node.js?

前端 未结 4 901
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 08:57

I am trying to connect to my CouchDB database on Cloudant using Node.js.

This worked on the shell:

    curl https://weng:password@weng.cloudant.com/m         


        
4条回答
  •  再見小時候
    2020-12-14 09:13

    This answer is looking a bit dated. Here is an updated answer that I verified using the following Cloudant Supported NPM Node Client library that works. https://www.npmjs.com/package/cloudant#getting-started

    And to answer his question on how to list his databases use the following code.

    //Specify your Cloudant Database Connection URL. For Bluemix format is: https://username:password@xxxxxxxxx-bluemix.cloudant.com
    
    dbCredentials_url = "https://username:password@xxxxxxxxx-bluemix.cloudant.com"; // Set this to your own account 
    
    // Initialize the library with my account. 
    // Load the Cloudant library. 
    cloudant = require('cloudant')(dbCredentials_url);
    
    // List the Cloudant databases
    cloudant.db.list(function(err, allDbs) {
    console.log('All my databases: %s', allDbs.join(', ')) });
    

提交回复
热议问题