Permalink
Commits on May 26, 2012
  1. Merge branch 'master' into view_changes

    benoitc committed May 26, 2012
    Conflicts:
    	apps/couch_changes/include/couch_changes.hrl
    	apps/couch_changes/src/couch_changes.erl
    	apps/couch_changes/src/couch_httpd_changes.erl
    	apps/couch_replicator/src/couch_replicator_api_wrap.erl
Commits on May 22, 2012
  1. don't use the ini to load couch_uuids.

    benoitc committed May 22, 2012
    This module is always needed, there is no need to keep it in the
    configuration file.
  2. extract couch_stats in its own app.

    benoitc committed May 22, 2012
    couch_stats is now a full erlang application booted at startup. Other
    changes are a better reinitialization of settings. Instead of exiting
    the gen_server, we just load new settings and overwrite older.
Commits on May 18, 2012
  1. support system dbs. close #9 .

    benoitc committed May 18, 2012
    Systems databases are databases only available and visible by admins.
    All systems databases are prefixed by `rc_` .
    
    Ex:
    
        $ curl -XPUT http://127.0.0.1:5984/rc_somesystemdb
        {"error":"unauthorized","reason":"You are not a server admin."}
        $ curl -XPUT http://admin:test@127.0.0.1:5984/rc_somesystemdb
        {"ok":true}
        $ curl http://admin:test@127.0.0.1:5984/_all_dbs
        ["_replicator","_users","rc_somesystemdb"]
        $ curl http://127.0.0.1:5984/_all_dbs
        ["_replicator","_users"]
        $ curl -XPUT http://admin:test@127.0.0.1:5984/rc_somesystemdb -d'{}'
        {"error":"file_exists","reason":"The database could not be created,
    the file already exists."}
        $ curl -XPUT http://admin:test@127.0.0.1:5984/rc_somesystemdb/test
    -d'{}'
        {"ok":true,"id":"test","rev":"1-967a00dff5e02add41819138abb3284d"}
        $ curl -XPUT http://127.0.0.1:5984/rc_somesystemdb/test1
    -d'{}'{"error":"unauthorized","reason":"You are not authorized to access
    this db."}
        $ curl
    http://127.0.0.1:5984/rc_somesystemdb/_all_docs{"error":"unauthorized","reason":"You
    are not authorized to access this db."}
        $ curl http://admin:test@127.0.0.1:5984/rc_somesystemdb/_all_docs
        {"total_rows":1,"offset":0,"rows":[
        {"id":"test","key":"test","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}
        ]}
Commits on May 17, 2012
  1. vhosts values should not be empty.

    benoitc committed May 17, 2012
    A vhost value can be empty when removed with the couch_config module.
Commits on May 16, 2012
  1. all should be compile & deps.

    benoitc committed May 16, 2012
  2. fix whitespaces

    benoitc committed May 16, 2012
  3. fix whitespaces

    benoitc committed May 16, 2012
Commits on May 12, 2012
  1. filter fields in included doc when returned from a _changes

    benoitc committed May 12, 2012
    With this changes you can only return a specified list of fields in the
    included docs by passing the list of them to an optionnal `fields`
    parameter. For now nested fields are ignored.
    
        $ curl -XPUT localhost:5984/testdb
        {"ok":true}
        $ curl -XPUT localhost:5984/testdb/test -d'{"f1": 1, "f2": 2, "f3":
    3}'
        {"ok":true,"id":"test","rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478"}
        $ curl -XPUT localhost:5984/testdb/test1 -d'{"f1": 1, "f2": 4, "f3":
    3}'
        {"ok":true,"id":"test1","rev":"1-2942771a428c4b45315710db0b6aaa7a"}
        $ curl -XPUT localhost:5984/testdb/test2 -d'{"f1": 1, "f2": 7, "f3":
    8}'
        {"ok":true,"id":"test2","rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3"}
        $ curl "http://localhost:5984/testdb/_changes?include_docs=true"
        {"results":[
        {"seq":1,"id":"test","changes":[{"rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478"}],"doc":{"_id":"test","_rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478","f1":1,"f2":2,"f3":3}},
        {"seq":2,"id":"test1","changes":[{"rev":"1-2942771a428c4b45315710db0b6aaa7a"}],"doc":{"_id":"test1","_rev":"1-2942771a428c4b45315710db0b6aaa7a","f1":1,"f2":4,"f3":3}},
        {"seq":3,"id":"test2","changes":[{"rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3"}],"doc":{"_id":"test2","_rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3","f1":1,"f2":7,"f3":8}}
        ],
        "last_seq":3}
        $ curl
    'http://localhost:5984/testdb/_changes?include_docs=true&fields=\["f1"\]'
        {"results":[
        {"seq":1,"id":"test","changes":[{"rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478"}],"doc":{"_id":"test","_rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478","f1":1}},
        {"seq":2,"id":"test1","changes":[{"rev":"1-2942771a428c4b45315710db0b6aaa7a"}],"doc":{"_id":"test1","_rev":"1-2942771a428c4b45315710db0b6aaa7a","f1":1}},
        {"seq":3,"id":"test2","changes":[{"rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3"}],"doc":{"_id":"test2","_rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3","f1":1}}
        ],
        "last_seq":3}
    
        $ curl
    'http://localhost:5984/testdb/_changes?include_docs=true&fields=\["f1","f2"\]'
        {"results":[
        {"seq":1,"id":"test","changes":[{"rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478"}],"doc":{"_id":"test","_rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478","f1":1,"f2":2}},
        {"seq":2,"id":"test1","changes":[{"rev":"1-2942771a428c4b45315710db0b6aaa7a"}],"doc":{"_id":"test1","_rev":"1-2942771a428c4b45315710db0b6aaa7a","f1":1,"f2":4}},
        {"seq":3,"id":"test2","changes":[{"rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3"}],"doc":{"_id":"test2","_rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3","f1":1,"f2":7}}
        ],
        "last_seq":3}
    
    Conflicts:
    
    	apps/couch_changes/src/couch_changes.erl
  2. filter fields in included doc when returned from a _changes

    benoitc committed May 12, 2012
    With this changes you can only return a specified list of fields in the
    included docs by passing the list of them to an optionnal `fields`
    parameter. For now nested fields are ignored.
    
        $ curl -XPUT localhost:5984/testdb
        {"ok":true}
        $ curl -XPUT localhost:5984/testdb/test -d'{"f1": 1, "f2": 2, "f3":
    3}'
        {"ok":true,"id":"test","rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478"}
        $ curl -XPUT localhost:5984/testdb/test1 -d'{"f1": 1, "f2": 4, "f3":
    3}'
        {"ok":true,"id":"test1","rev":"1-2942771a428c4b45315710db0b6aaa7a"}
        $ curl -XPUT localhost:5984/testdb/test2 -d'{"f1": 1, "f2": 7, "f3":
    8}'
        {"ok":true,"id":"test2","rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3"}
        $ curl "http://localhost:5984/testdb/_changes?include_docs=true"
        {"results":[
        {"seq":1,"id":"test","changes":[{"rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478"}],"doc":{"_id":"test","_rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478","f1":1,"f2":2,"f3":3}},
        {"seq":2,"id":"test1","changes":[{"rev":"1-2942771a428c4b45315710db0b6aaa7a"}],"doc":{"_id":"test1","_rev":"1-2942771a428c4b45315710db0b6aaa7a","f1":1,"f2":4,"f3":3}},
        {"seq":3,"id":"test2","changes":[{"rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3"}],"doc":{"_id":"test2","_rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3","f1":1,"f2":7,"f3":8}}
        ],
        "last_seq":3}
        $ curl
    'http://localhost:5984/testdb/_changes?include_docs=true&fields=\["f1"\]'
        {"results":[
        {"seq":1,"id":"test","changes":[{"rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478"}],"doc":{"_id":"test","_rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478","f1":1}},
        {"seq":2,"id":"test1","changes":[{"rev":"1-2942771a428c4b45315710db0b6aaa7a"}],"doc":{"_id":"test1","_rev":"1-2942771a428c4b45315710db0b6aaa7a","f1":1}},
        {"seq":3,"id":"test2","changes":[{"rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3"}],"doc":{"_id":"test2","_rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3","f1":1}}
        ],
        "last_seq":3}
    
        $ curl
    'http://localhost:5984/testdb/_changes?include_docs=true&fields=\["f1","f2"\]'
        {"results":[
        {"seq":1,"id":"test","changes":[{"rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478"}],"doc":{"_id":"test","_rev":"1-2b23983c05a9ca8015b6ea7bdc1b3478","f1":1,"f2":2}},
        {"seq":2,"id":"test1","changes":[{"rev":"1-2942771a428c4b45315710db0b6aaa7a"}],"doc":{"_id":"test1","_rev":"1-2942771a428c4b45315710db0b6aaa7a","f1":1,"f2":4}},
        {"seq":3,"id":"test2","changes":[{"rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3"}],"doc":{"_id":"test2","_rev":"1-ac4cd62a83a0a98421e9ed74adcadcc3","f1":1,"f2":7}}
        ],
        "last_seq":3}
Commits on May 11, 2012
  1. fix purge

    benoitc committed Apr 10, 2012
  2. Revert "fix include:"

    benoitc committed Mar 27, 2012
    This reverts commit ed0076d3fdbf2b2cf28acb204f48fe07db65440f.
  3. fix include:

    benoitc committed Mar 27, 2012
  4. change order

    benoitc committed Mar 27, 2012
  5. fix imports

    benoitc committed Mar 23, 2012
  6. Get view changes using a view query.

    benoitc committed Feb 26, 2012
    Add the possibility to the function `couch_mrview:view_changes_since` to
    accept some **view query parameters** like `key`, `start_key` &
    `end_key`. Instead of fetching all changes in a view from last updated
    it will fetch changes only from the results of the query.  It returns an
    error  if the option `seq_indexed` hasn't been set to `true` in the
    view options:
    
            {
                "_id": "_design/somedoc",
                "views": {
                    "someview": {
                        "map": "function(doc) { if (doc.field)
    emit(doc.field, null); }",
                        "options": {
                            "seq_indexed": "true"
                        }
                    }
                }
            }
    
    This is done by adding an index (b-tree) to each view. This index
    associate the view key with the doc sequence. `{{Key, Seq}, {DocId, Value}}`
    is stored in this btree.
  7. add support for `include_deleted: true` option in a design document.

    benoitc committed Feb 26, 2012
    This option allows a view to map deleted documents.
    
    Remember that documents deleted with the DELETE HTTP verb will look like
    {_id: id, _rev: rev, _deleted: true} to the indexer. If you want to
    store extra data on the deleted document you can use _bulk_docs or
    updating a document with the member '_deleted: true' using the HTTP verb
    PUT.
  8. fix _changes test

    benoitc committed Feb 29, 2012
    The `_view` filter now need a view group indexed by sequences.
  9. `_view` filter is now hanled by couch_mrview:view_changes_since/7

    benoitc committed Feb 23, 2012
    Rather than passing all doc sent y couch_db:changes_since/5 to a
    transformed view function we are now using the more efficient
    `couch_mrview:view_changes_since/7` wich use the seq btree in the view
    group.
    
    Also add the parameters `view_filter=DName/FilterName` which allows to
    filter any view changes using the fiter function `FilterName` from the
    design document `DName`:
    
       GET http://<node>/<dbname>/_changes?filter=_view&view=<viewname>&view_filter<filtername>
    
    Where variables are:
    
    - <node>: URL of the CouchDB node
    - <dbname>: Name of the database
    - <viewname>: DesignId/ViewNameThe name of the view in the views properties
      from the design document DesignId`
    - <filtername>: DesignId1/FilterName The name of the filter in
      the filters properties from the design document DesignId1
    
    The difference with the old behaviour is that you really accessing the
    view index instead of passing each map function to all the changed docs
    wich is a way more efficient (you do'nt open a system process, serialize
    the function, pass it to the process, wait for return, test it and
    eventually return a change). You can also filter the results. Other
    advantages are that the views are refreshed in real time when the
    database content changes and the view changes are only triggered if the
    index is updated.
  10. Add `couch_mrview:view_changes_since` function.

    benoitc committed Feb 22, 2012
    This functions fetch all changes in a view since last update like the
    `couch_db:changes_since` function for the databases. It returns an error
    if the option `seq_indexed` hasn't been set to `true` in the design
    document:
    
        {
            "_id": "_design/somedoc",
            "options": {
                "seq_indexed": "true"
            },
            "views": {
                "someview": {
                    "map": "function(doc) { if (doc.field) emit(doc.field, null); }"
                }
            }
        }
    
    This is done by adding an index to the view group (a view group is the
    global index associated to a design doc basically). This index associate
    each sequences & documents ID to a view . `{{ViewId, Seq}, DocId} is
    stored in the seq_btree, DocId is the value.
    
    example of usage:
    
        (refuge@127.0.0.1)3> F = fun(KV, Acc) -> {ok, [KV|Acc]} end.
        (refuge@127.0.0.1)4>
        (refuge@127.0.0.1)4> couch_mrview:view_changes_since(Db, DDoc,
    <<"all">>, 9990, F).
        [info] [<0.220.0>] Opening index for db: testdb idx: _design/test
    sig:
        "85b8fa1e39dc7fbe8b11b729b319c6bf"
        {ok,[{10000,{<<"72f9250618e65adc8cf4552758fff137">>,0}},
             {9999,{<<"72f9250618e65adc8cf4552758ffe85d">>,0}},
             {9998,{<<"72f9250618e65adc8cf4552758ffdbcf">>,0}},
             {9997,{<<"72f9250618e65adc8cf4552758ffd65e">>,0}},
             {9996,{<<"72f9250618e65adc8cf4552758ffd611">>,0}},
             {9995,{<<"72f9250618e65adc8cf4552758ffd045">>,0}},
             {9994,{<<"72f9250618e65adc8cf4552758ffc982">>,0}},
             {9993,{<<"72f9250618e65adc8cf4552758ffbfdb">>,0}},
             {9992,{<<"72f9250618e65adc8cf4552758ffb1fc">>,0}},
             {9991,{<<"72f9250618e65adc8cf4552758ffae18">>,0}}]}
        (refuge@127.0.0.1)5>
        (refuge@127.0.0.1)5> couch_mrview:view_changes_since(Db, DDoc,
    <<"all">>, 10000, F).
        {ok,[]}
        (refuge@127.0.0.1)7> couch_mrview:view_changes_since(Db, DDoc,
    <<"all">>, 10000, F).
        {ok,[{10002,{<<"31b0c9f8353b6b3e2a86c23d2c000a78">>,0}}]}
Commits on May 10, 2012
  1. add support of Server-Sent Events protocol to db changes API.

    benoitc committed May 10, 2012
    This patch add support for the new specification of w3c by adding a new
    feed type named `eventsource`:
    
    http://www.w3.org/TR/2009/WD-eventsource-20090423/
    
    ex:
    
        $ curl
    'http://127.0.0.1:5984/testdb/_changes?feed=eventsource&heartbeat=true&timeout=10000'
        data:
    {"seq":1,"id":"test","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
        id: 1
    
        data:
    {"seq":2,"id":"test1","changes":[{"rev":"1-967a00dff5e02add41819138abb3284d"}]}
        id: 2
Commits on May 7, 2012
  1. Add dropbox databases support.

    benoitc committed May 7, 2012
    Dropobx databases are databases only acceping write but can only be read
    by selected users. Only nodes' admins or dropbox members can read
    documents
    that have  been dropped in a dropbox database.
    
    To mark a database as a Drop Box, add the property `{"dropbox": true}`
    to the security object.
    
    Dropbox members are admins (global or db admins) and users sets in the
    `dropbox_members` property:
    
        {"dropbox_members": {"names": [], "roles": []}}
    
    Example of usage:
    
        $ curl -XPUT admin:test@127.0.0.1:5984/testdb
        {"ok":true}
        $ curl -XPUT 127.0.0.1:5984/testdb/test -d'{}'
        {"ok":true,"id":"test","rev":"1-967a00dff5e02add41819138abb3284d"}
        $ curl -XPUT 127.0.0.1:5984/testdb/test1 -d'{}'
        {"ok":true,"id":"test1","rev":"1-967a00dff5e02add41819138abb3284d"}
        $ curl -XGET 127.0.0.1:5984/testdb/_all_docs
        {"total_rows":2,"offset":0,"rows":[
        {"id":"test","key":"test","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
        {"id":"test1","key":"test1","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}]}
        $ curl -XGET 127.0.0.1:5984/testdb/test1
        {"_id":"test1","_rev":"1-967a00dff5e02add41819138abb3284d"}
        $ curl -XPUT admin:test@127.0.0.1:5984/testdb/_security -d'{"dropbox": true}'
        {"ok":true}
        $ curl -XGET 127.0.0.1:5984/testdb/test1
        {"error":"forbidden","reason":"Only administrators can view docs in a dropbox database."}
        $ curl -XGET 127.0.0.1:5984/testdb/_all_docs
        {"error":"forbidden","reason":"Only admins can access _all docs"}
        $ curl -XPUT 127.0.0.1:5984/testdb/test2 -d'{}'
        {"ok":true,"id":"test2","rev":"1-967a00dff5e02add41819138abb3284d"}
        $ curl -XGET 127.0.0.1:5984/testdb/test2
        {"error":"forbidden","reason":"Only administrators can view docs in a dropbox database."}
        $ curl -XGET admin:test@127.0.0.1:5984/testdb/_all_docs
        {"total_rows":3,"offset":0,"rows":[
        {"id":"test","key":"test","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
        {"id":"test1","key":"test1","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
        {"id":"test2","key":"test2","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}
        ]}
  2. make sure that ClearPassword string is handled.

    benoitc committed May 7, 2012
    When you set a clear password in the config, the
    `couch_passwords:hash_admin_password/1` get a string instead of a
    binary.
Commits on May 5, 2012
  1. Added Magnus Hoff to apps/couch/THANKS

    dch authored and benoitc committed Apr 30, 2012
  2. Merged pull request #19 from @maghoff with thanks

    maghoff authored and benoitc committed Apr 28, 2012
    Fix failed loading of CommonJS modules that end in a line comment.
  3. Use TEquals for great good

    rnewson authored and benoitc committed Apr 26, 2012
  4. Silence compiler warning

    davisp authored and benoitc committed Apr 25, 2012