Last active
August 29, 2015 14:03
-
-
Save jeffcogswell/de7e552671780011b9f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
nano doesn't yet have support for Cloudant's new index feature, | |
but you can still do it using nano's request function. | |
This code queries an index. | |
To try this, first replicate the database as per | |
instructions here and make sure you created an index. | |
(Also check out my node.js code to create the index | |
here:https://gist.github.com/jeffcogswell/1c2f06f5dcd152c055b6) | |
Then install nano like so: | |
npn install nano | |
And then run this file (after replacing USERNAME | |
and PASSWORD with your own): | |
node query_C_index.js | |
*/ | |
var nano = require('nano')({ url: 'https://[USERNAME]:[PASSWORD]@[USERNAME].cloudant.com' }); | |
var query = { "selector": { "Person_name": "Zoe Saldana" } }; | |
var opts = { | |
path: '_find', | |
db: 'movies-demo', | |
method: 'post', | |
body: query | |
}; | |
nano.request(opts, function(err, result) { | |
// err should be null | |
console.log(err); | |
// result should be a list containing info about the movie Avatar | |
console.log(result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment