Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
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]' });
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
// result should be a list containing info about the movie Avatar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment