Code Monkey home page Code Monkey logo

couch_randomdoc's Introduction

couch_randomdoc

couch_randomdoc is a simple couchdb module to add support of random document fetching. It allows you to fetch doc via teh HTTP Api, filter them and even render them dirrently using a show function.

It's actually supported by all the refuge projects:

Note: A port as an Apache Couchdb plugin is in progress.

HTTP API

To get a random doc do a GET to /<db>/_random_doc .

All options od the couchdb DOC APII can be applied.

An optionna parameter filter allows you to filter random document you want to return. a filter functions is just like changes filters:

GET /<db>/_random_doc?filter=DesignName/FuncName

There are also builtin filters:

  • _prefix: prefix you want to filter, Pass the prefix using the prefix parameter:

      GET /<db>/_random_doc?filter=_prefix&prefix=someprefix
    
  • _design_doc: to only return design document

  • _view: get a random document from a view index. Pass the view name uing the view parameter:

      GET /<db>/_random_doc?filter=_view&view=DesignName/ViewName
    

SHOW function

Like show function you may want to render your random documents diffently:

    GET /<db>/_design/DesignName/_random/ShowFunction

Functions are put in the shows property of the design document like any shows functions.

couch_randomdoc's People

Contributors

benoitc avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rcouch chinnurtb

couch_randomdoc's Issues

Add _random_docs?limit=5

I think it would be useful to be able to retrieve multiple random docs, limited by a certain amount of documents. By default it should probably be just 5 or something, because it could get somewhat inefficient with a high number of docs. Returned docs should be unique. Order could be random too.

Now that I think about it, wouldn't it make sense to be able to get random entries from a view (instead)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.