couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Shorin <kxe...@gmail.com>
Subject Re: Database information from validate_doc_update
Date Sat, 09 Nov 2013 05:40:46 GMT
Currently, this is possible only via native Erlang query server:

fun(NewDoc, OldDoc, {UserCtx}, SecObj) ->
  DbName = couch_util:get_value(<<"db">>, UserCtx),
  {ok, Db} = couch_db:open_int(DbName, [{user_ctx, UserCtx}]),
  {ok, Info} = couch_db:get_db_info(Db),
  DiskSize = couch_util:get_value(disk_size, Info),
  case DiskSize < 100000 of  %% ~100KB
    true ->
      ok;
    false ->
      throw({[{<<"forbidden">>, <<"quota limit reached">>}]})
  end,
  1
end.



--
,,,^..^,,,


On Sat, Nov 9, 2013 at 7:56 AM, first-leon@yandex.ru
<first-leon@yandex.ru> wrote:
> Hello.
>
> Can I get information about the database as a function of
> validate_doc_update? For example, to find out the size of the database or
> the number of documents.
>
> Example:
> function(newDoc, oldDoc, userCtx) {
>  if ( thisDb.disk_size > 1000 ) throw({forbidden : 'you have exceeded the
> limit'});
> }
>
> It is possible?
>
> Thanks.

Mime
View raw message