Re: Database information from validate_doc_update
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 10 of %% ~100KB true - ok; false - throw({[{forbidden, quota limit reached}]}) end, 1 end. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 7:56 AM, first-l...@yandex.ru first-l...@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.
Re: Database information from validate_doc_update
validate_doc_update functions deliberately don't let you do this otherwise eventually consistency can be compromised. Also remember that the native view server has no sandbox, anyone allowed to edit design documents can do anything to your servers that the user you run couchdb as can (read files, open network connections, delete files, etc). B. On 9 November 2013 09:02, first-l...@yandex.ru first-l...@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 10 of %% ~100KB true - ok; false - throw({[{forbidden, quota limit reached}]}) end, 1 end. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 7:56 AM, first-l...@yandex.ru first-l...@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.
Re: Database information from validate_doc_update
And i not possible get information about data base from validate_doc_update? validate_doc_update functions deliberately don't let you do this otherwise eventually consistency can be compromised. Also remember that the native view server has no sandbox, anyone allowed to edit design documents can do anything to your servers that the user you run couchdb as can (read files, open network connections, delete files, etc). B. On 9 November 2013 09:02, first-l...@yandex.ru first-l...@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 10 of %% ~100KB true - ok; false - throw({[{forbidden, quota limit reached}]}) end, 1 end. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 7:56 AM, first-l...@yandex.ru first-l...@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.
Re: Database information from validate_doc_update
Deliberately not, no, a validate_doc_update function is only passed the new document you're trying to update, the current one (if there is one), the context of the user and the security object for the database. B. On 9 November 2013 11:00, first-l...@yandex.ru first-l...@yandex.ru wrote: And i not possible get information about data base from validate_doc_update? validate_doc_update functions deliberately don't let you do this otherwise eventually consistency can be compromised. Also remember that the native view server has no sandbox, anyone allowed to edit design documents can do anything to your servers that the user you run couchdb as can (read files, open network connections, delete files, etc). B. On 9 November 2013 09:02, first-l...@yandex.ru first-l...@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 10 of %% ~100KB true - ok; false - throw({[{forbidden, quota limit reached}]}) end, 1 end. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 7:56 AM, first-l...@yandex.ru first-l...@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.
Re: Database information from validate_doc_update
I want set limit base document count. And now i see one way: 1) In Change Notifications function i see count document in base 2) if size of database larger given: replace validate_doc_update function and denied create new docs. It is long and slow way. Maybe someone will tell a better implementation? Deliberately not, no, a validate_doc_update function is only passed the new document you're trying to update, the current one (if there is one), the context of the user and the security object for the database. B. On 9 November 2013 11:00, first-l...@yandex.ru first-l...@yandex.ru wrote: And i not possible get information about data base from validate_doc_update? validate_doc_update functions deliberately don't let you do this otherwise eventually consistency can be compromised. Also remember that the native view server has no sandbox, anyone allowed to edit design documents can do anything to your servers that the user you run couchdb as can (read files, open network connections, delete files, etc). B. On 9 November 2013 09:02, first-l...@yandex.ru first-l...@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 10 of %% ~100KB true - ok; false - throw({[{forbidden, quota limit reached}]}) end, 1 end. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 7:56 AM, first-l...@yandex.ru first-l...@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.
Re: Database information from validate_doc_update
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-l...@yandex.ru first-l...@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 10 of %% ~100KB true - ok; false - throw({[{forbidden, quota limit reached}]}) end, 1 end. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 7:56 AM, first-l...@yandex.ru first-l...@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.
Re: Database information from validate_doc_update
Yes! It work for me on CouchDB 1.3. But on CouchDB 1.4 not worked :( Thanks! 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-l...@yandex.ru first-l...@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 10 of %% ~100KB true - ok; false - throw({[{forbidden, quota limit reached}]}) end, 1 end. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 7:56 AM, first-l...@yandex.ru first-l...@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.
Re: Database information from validate_doc_update
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 10 of %% ~100KB true - ok; false - throw({[{forbidden, quota limit reached}]}) end, 1 end. -- ,,,^..^,,, On Sat, Nov 9, 2013 at 7:56 AM, first-l...@yandex.ru first-l...@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.