> cat package.json
{
"name": "Node_tutorial",
"description": "My test node tutorial",
"version":"0.1.0",
"author": "David Chang",
"dependencies": {
"nano": "1.1.x"
}
}
> npm install
> cat couch.js
var nano = require('nano');
var server = nano('http://XXX:YYY@dmak168.iriscouch.com');
server.db.create('mydb2', function(err){
if (err) { throw err; }
console.log('created mydb');
var doc1 = { a:1, b:2, c: "abd", d: [1, 2, 3] };
var db = server.use('mydb2');
db.insert(doc1, "doc_two", function(err){
if (err) { throw err; }
console.log('inserted obj1');
db.get('doc_two', function(err, val) {
console.log('doc_two = ', val);
});
});
});
> node couch.js
created mydb
inserted obj1
doc_two = { _id: 'doc_two',
_rev: '1-f83339c44679257161b912dd6aad89dd',
a: 1,
b: 2,
c: 'abd',
d: [ 1, 2, 3 ] }
No comments:
Post a Comment