Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C589D102E2 for ; Sat, 9 Nov 2013 15:21:58 +0000 (UTC) Received: (qmail 74597 invoked by uid 500); 9 Nov 2013 15:21:56 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 74569 invoked by uid 500); 9 Nov 2013 15:21:55 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 74556 invoked by uid 99); 9 Nov 2013 15:21:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Nov 2013 15:21:51 +0000 X-ASF-Spam-Status: No, hits=0.3 required=5.0 tests=FREEMAIL_REPLY,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of kxepal@gmail.com designates 74.125.82.178 as permitted sender) Received: from [74.125.82.178] (HELO mail-we0-f178.google.com) (74.125.82.178) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Nov 2013 15:21:45 +0000 Received: by mail-we0-f178.google.com with SMTP id q59so3172257wes.9 for ; Sat, 09 Nov 2013 07:21:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=hcHKpU0m25AB9tdUTT4f5h9ZEOU61VUT3c6RAyToiVI=; b=wti/6c+mZRN6NziN228XRFmSqOe7RBywKiCeXr/q3I6R/gjX97WX+Qcm1SZUHVRfdF gpRXWzu8MxqIJwfMjpGthNFl411WU2kbXIfKG5yTLM2LcTXcYlB6ygO3EZMm/hBKFUwf YTDgJ1Tdjh/V3aDn31GNZQlJvAr1uzvyGMBL0wl6IW0WuMSlHEgVoCuXLIdP5xmblp/j jQM+bSeQXbFAX+TttuNXw1NsMtOU3h+YXF4rJX2KxLAsEOPiHnQZM9MPkLD3u2CcrWdi 92HpHAGIyLN1hJNKzOsDDI69MfN9+/HjK/K5osGtgpBAdwqeL/Cu07107nhc43xjtn4X Q2eA== MIME-Version: 1.0 X-Received: by 10.194.11.38 with SMTP id n6mr16572080wjb.25.1384010485293; Sat, 09 Nov 2013 07:21:25 -0800 (PST) Received: by 10.180.24.99 with HTTP; Sat, 9 Nov 2013 07:21:25 -0800 (PST) In-Reply-To: <527DFA30.6020306@yandex.ru> References: <527DB28B.20203@yandex.ru> <527DFA30.6020306@yandex.ru> Date: Sat, 9 Nov 2013 19:21:25 +0400 Message-ID: Subject: Re: Database information from validate_doc_update From: Alexander Shorin To: "user@couchdb.apache.org" Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Hm..it works for me on CouchDB 1.5, but as Robert said, using native query server is dangerous and since it's completely undocumented and may use internal CouchDB API there is no any warranties that code will work correctly in future releases. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 1:02 PM, first-leon@yandex.ru wrote: > It is very good! > But, i create validation function and see error: > > Error: EXIT > > {{badmatch,[]}, > [{couch_query_servers,new_process,3, > [{file,"couch_query_servers.erl"},{line,472}]}, > {couch_query_servers,lang_proc,3, > [{file,"couch_query_servers.erl"},{line,462}]}, > {couch_query_servers,handle_call,3, > [{file,"couch_query_servers.erl"},{line,322}]}, > {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,585}]}, > {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]} > > I am not understand Erlang code, and not see error details. > You have it working? > > In /etc/couchdb/local.ini i added > [native_query_servers] > erlang = {couch_native_process, start_link, []} > > >> 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 >> 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. > >