Coder Social home page Coder Social logo

couchdb_ruby_view's Introduction

Installation
------------
Copy bin/couchdb_ruby_view to somewhere like /usr/local/bin, and make
sure it is executable.

Edit /usr/local/etc/couchdb/local.ini and set:

[query_servers]
ruby = /usr/local/bin/couchdb_ruby_view

or

ruby = /path/to/ruby /usr/local/bin/couchdb_ruby_view

Restart couchdb.

API
---
map:

  proc { |doc|
    ...
    emit(key,val)
    ...
  }

reduce/rereduce:

  proc { |ks,vs,rereduce|
    vs.inject(0) { |a,b| a+b }
  }

Note that CouchDB actually passes objects which could be iterated directly
using { |(k,id),v| ... }. However I've split these into separate arrays of
[k,id] and v for consistency with the Javascript view server, and because it
simplifies some reduce/rereduce functions (as in the example above, where
both reduce and rereduce are the same)

*** IMPORTANT SECURITY WARNING ***
----------------------------------
DON'T USE THIS CODE IF UNTRUSTED USERS HAVE DIRECT ACCESS TO YOUR DATABASE!
They will be able to run *any* code or read/write *any* file as the couchdb
user if they can post to _temp_view or update design documents.

TODO: improve this by compiling and running the functions in a separate
thread with $SAFE=4.  There is also _why's ruby sandbox gem, although this
requires a small patch to the ruby interpreter itself.

ALSO TODO
---------
If map/reduce functions define helper methods using 'def', they should do
this inside a singleton class rather than globally.

Authors
-------
Johan Sørensen <[email protected]>
Brian Candler <[email protected]>

couchdb_ruby_view's People

Contributors

candlerb avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.