Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. require('dotenv').load();
  2.  
  3. var Cloudant = require('cloudant');
  4. var username = process.env.cloudant_username;
  5. var password = process.env.cloudant_password;
  6.  
  7. var cloudant = Cloudant({account:username, password:password});
  8. var db = cloudant.db.use('DATABASE');
  9.  
  10. // Normal operation
  11. db.find({selector:{name:'NAME'}}, function(er, result) {
  12. if (er) {
  13. console.log(er);
  14. } else {
  15. console.log('Found %d documents with name NAME', result.docs.length);
  16. }
  17. });
  18.  
  19. // Should error once, and terminate
  20. db.find('', function(er, result) {
  21. if (er) {
  22. console.log(er);
  23. } else {
  24. console.log('Found %d documents with name NAME', result.docs.length);
  25. }
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement