0
0

More than 3 years have passed since last update.

Node.js: CouchDB のデータを読む (Read)

Posted at
couch_read.js
#! /usr/bin/node
// ---------------------------------------------------------------
//  couch_read.js
//
//                  Jul/27/2020
// ---------------------------------------------------------------
var Client = require('node-rest-client').Client

// ---------------------------------------------------------------
console.error("*** 開始 ***")

var client = new Client()

const url = "http://localhost:5984/nagano/_all_docs?include_docs=true"

client.get(url, function(data, response) {

    data.rows.forEach (function(row)
        {
        var out_str = row.id + "\t"
        out_str += row.doc.name + "\t"
        out_str += row.doc.population + "\t"
        out_str += row.doc.date_mod;
        console.log (out_str)
        })

    console.error("*** 終了 ***")
})

// ---------------------------------------------------------------

実行

export NODE_PATH=/usr/lib/node_modules
./couch_read.js
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0