[ANNOUNCE] CouchDB will go multilingual - looking for contributors!

2013-11-09 Thread Andy Wenk
Hi,

this is the first announcement regarding the efforts to integrate L10N into
CouchDB. A new blog post is available [1] and we kindly ask you to like and
reshare the posts [2] in the different social media portals.

The efforts are still in a very early stage. The work on including the
creation of translation files (.po, .pot) and the documentation html output
in different languages into the build process has started. For the
translation work the ASF translation service pootle [3] will be used.

Are you interested in helping? We are happy hearing from you. Please
subscribe to l...@couchdb.apache.org and get in touch. Thank you!

Cheers

Andy

[1]
https://blogs.apache.org/couchdb/entry/couchdb_will_go_multilingual_looking
[2] Please like and reshare the following links:
https://plus.google.com/110705229183006710621/posts/25QiooL3rEc
https://news.ycombinator.com/item?id=6703574
http://www.reddit.com/r/CouchDB/comments/1q9uup/couchdb_will_go_multilingual_looking_for/
http://www.reddit.com/r/programming/comments/1q9qjq/couchdb_will_go_multilingual_looking_for/
http://www.reddit.com/r/Database/comments/1q9rz4/couchdb_will_go_multilingual_looking_for/
http://www.reddit.com/r/nosql/comments/1q9sp3/couchdb_will_go_multilingual_looking_for/
https://twitter.com/awenkhh/status/399306248668999681
[3] https://translate.apache.org/projects/CouchDB/

-- 
Andy Wenk
Hamburg - Germany
RockIt!

http://www.couchdb-buch.de
http://www.pg-praxisbuch.de

GPG fingerprint: C044 8322 9E12 1483 4FEC 9452 B65D 6BE3 9ED3 9588


RE: CouchDb startup error: Failure to start Mochiweb

2013-11-09 Thread Keith Gable
That should be sudo service couchdb start :-) From: Keith Gable
Sent: 11/9/2013 17:11
To: Alexander Gabriel; user@couchdb.apache.org
Subject: RE: CouchDb startup error: Failure to start Mochiweb
There should be an init script. Try:
service couchdb start

If that doesn't work:
sudo su -u couchdb couchdb From: Alexander Gabriel
Sent: 11/9/2013 15:27
To: user@couchdb.apache.org
Subject: CouchDb startup error: Failure to start Mochiweb
Hi experts

I've installed a droplet at digitaloceans.com using ubuntu 13.10, because
it is easy to install couchdb 1.4 on it as it's included in the software
repository.

So I ran "sudo apt-get install couchdb -y" and as far as I remember there
were no errors.

But when I run "sudo -i -u couchdb couchdb" I get the error mentioned here:
http://wiki.apache.org/couchdb/Error_messages#Unavailable_Port. The page
says: "Edit your /etc/couchdb/couch.ini file and change the Port setting to
an available port"

When I run "nmap -v www.arteigenschaften.ch" I get only one open port:
22/tcp (service: ssh) and 999 closed ports.

I'm a bit surprised that port 90 isn't open. But maybe that is because
nobody is listening yet?

If I understand correctly the fact that port 5984 isn't open also means
that no one is listening. But then why should I change to an available port
when the problem is not the port but the listener? Would "not available"
mean that someone else is already listening? But then the fact that port
5984 is not "open" would mean that the problem isn't in the port but
somewhere else.

"ufw status" > "inactive". So no firewall blocking (not sure if this would
be relevant for connecting to localhost)

"sudo iptables -A INPUT -p tcp --dport 5984 -j ACCEPT" didn't help

I guess now is the time to mention that I'm a linux and ip noob. Surely
there's something glaringly obvious that I'm unaware of?

In case it's any help: www.barbalex.ch/downloads/erl_crash.dump

Alex


RE: CouchDb startup error: Failure to start Mochiweb

2013-11-09 Thread Keith Gable
There should be an init script. Try:
service couchdb start

If that doesn't work:
sudo su -u couchdb couchdb From: Alexander Gabriel
Sent: 11/9/2013 15:27
To: user@couchdb.apache.org
Subject: CouchDb startup error: Failure to start Mochiweb
Hi experts

I've installed a droplet at digitaloceans.com using ubuntu 13.10, because
it is easy to install couchdb 1.4 on it as it's included in the software
repository.

So I ran "sudo apt-get install couchdb -y" and as far as I remember there
were no errors.

But when I run "sudo -i -u couchdb couchdb" I get the error mentioned here:
http://wiki.apache.org/couchdb/Error_messages#Unavailable_Port. The page
says: "Edit your /etc/couchdb/couch.ini file and change the Port setting to
an available port"

When I run "nmap -v www.arteigenschaften.ch" I get only one open port:
22/tcp (service: ssh) and 999 closed ports.

I'm a bit surprised that port 90 isn't open. But maybe that is because
nobody is listening yet?

If I understand correctly the fact that port 5984 isn't open also means
that no one is listening. But then why should I change to an available port
when the problem is not the port but the listener? Would "not available"
mean that someone else is already listening? But then the fact that port
5984 is not "open" would mean that the problem isn't in the port but
somewhere else.

"ufw status" > "inactive". So no firewall blocking (not sure if this would
be relevant for connecting to localhost)

"sudo iptables -A INPUT -p tcp --dport 5984 -j ACCEPT" didn't help

I guess now is the time to mention that I'm a linux and ip noob. Surely
there's something glaringly obvious that I'm unaware of?

In case it's any help: www.barbalex.ch/downloads/erl_crash.dump

Alex


CouchDb startup error: Failure to start Mochiweb

2013-11-09 Thread Alexander Gabriel
Hi experts

I've installed a droplet at digitaloceans.com using ubuntu 13.10, because
it is easy to install couchdb 1.4 on it as it's included in the software
repository.

So I ran "sudo apt-get install couchdb -y" and as far as I remember there
were no errors.

But when I run "sudo -i -u couchdb couchdb" I get the error mentioned here:
http://wiki.apache.org/couchdb/Error_messages#Unavailable_Port. The page
says: "Edit your /etc/couchdb/couch.ini file and change the Port setting to
an available port"

When I run "nmap -v www.arteigenschaften.ch" I get only one open port:
22/tcp (service: ssh) and 999 closed ports.

I'm a bit surprised that port 90 isn't open. But maybe that is because
nobody is listening yet?

If I understand correctly the fact that port 5984 isn't open also means
that no one is listening. But then why should I change to an available port
when the problem is not the port but the listener? Would "not available"
mean that someone else is already listening? But then the fact that port
5984 is not "open" would mean that the problem isn't in the port but
somewhere else.

"ufw status" > "inactive". So no firewall blocking (not sure if this would
be relevant for connecting to localhost)

"sudo iptables -A INPUT -p tcp --dport 5984 -j ACCEPT" didn't help

I guess now is the time to mention that I'm a linux and ip noob. Surely
there's something glaringly obvious that I'm unaware of?

In case it's any help: www.barbalex.ch/downloads/erl_crash.dump

Alex


Re: Storage limitations?

2013-11-09 Thread Robert Newson
attachments are different to documents. They're stored as a series of
binary chunks and so they can be streamed in and out, you can go large
with attachments. The reason I say documents can't be too huge is that
couchdb has to hold them in memory to process them or even return
them.

As for comments, just add new documents for each comment and use a
view (https://wiki.apache.org/couchdb/HTTP_view_API,
https://wiki.apache.org/couchdb/View_collation) to bring the article
and comment thread together. No need to update a document that way.

B.


On 9 November 2013 19:31, Mark Hahn  wrote:
>> sorting/displaying a comments thread with replies by appending the replies
> within their respective original comment field.
>
> Wouldn't it be more natural to use an array?  And it would be more flexible
> for possible future changes.  It doesn't affect the size of the field but
> there is no way a comment thread is going to get up to even a megabyte.
>  The entire bible fits in a megabyte.
>
>
> On Sat, Nov 9, 2013 at 9:22 AM, Mark Deibert  wrote:
>
>> Ok I was assuming the db could be really big. I'm storing images so it
>> _will_ get pretty large.
>>
>> For the field size question: I had an idea to greatly simplify
>> sorting/displaying a comments thread with replies by appending the replies
>> within their respective original comment field. Since the order I want to
>> display the comments is the natural chronological order, a simple append
>> process seems to make sense. Haven't tried yet but seems logical.
>>
>>
>> On Sat, Nov 9, 2013 at 11:32 AM, Robert Newson  wrote:
>>
>> > while the default configuration has max_document_size as 4Gb, it would
>> > be very unwise to make a document anywhere near that large. Database
>> > size is limited only by disk capacity but note that you'll need some
>> > free space for compacting the database.
>> >
>> > On 9 November 2013 15:28, first-l...@yandex.ru 
>> > wrote:
>> > > Base size in no limit. But file system may be limit by file size.
>> > > Doc size limit is 4Gb. (one or two or more field: total - 4Gb)
>> > >
>> > >> I have two storage questions. How big can any one field in one doc be?
>> > >> Also, is there any limit on the size of a CouchDB? Meaning, if I have
>> > 1TB
>> > >> of free disk space, will the db grow to 1TB in size?
>> > >>
>> > >
>> >
>>


Re: Storage limitations?

2013-11-09 Thread Mark Hahn
> sorting/displaying a comments thread with replies by appending the replies
within their respective original comment field.

Wouldn't it be more natural to use an array?  And it would be more flexible
for possible future changes.  It doesn't affect the size of the field but
there is no way a comment thread is going to get up to even a megabyte.
 The entire bible fits in a megabyte.


On Sat, Nov 9, 2013 at 9:22 AM, Mark Deibert  wrote:

> Ok I was assuming the db could be really big. I'm storing images so it
> _will_ get pretty large.
>
> For the field size question: I had an idea to greatly simplify
> sorting/displaying a comments thread with replies by appending the replies
> within their respective original comment field. Since the order I want to
> display the comments is the natural chronological order, a simple append
> process seems to make sense. Haven't tried yet but seems logical.
>
>
> On Sat, Nov 9, 2013 at 11:32 AM, Robert Newson  wrote:
>
> > while the default configuration has max_document_size as 4Gb, it would
> > be very unwise to make a document anywhere near that large. Database
> > size is limited only by disk capacity but note that you'll need some
> > free space for compacting the database.
> >
> > On 9 November 2013 15:28, first-l...@yandex.ru 
> > wrote:
> > > Base size in no limit. But file system may be limit by file size.
> > > Doc size limit is 4Gb. (one or two or more field: total - 4Gb)
> > >
> > >> I have two storage questions. How big can any one field in one doc be?
> > >> Also, is there any limit on the size of a CouchDB? Meaning, if I have
> > 1TB
> > >> of free disk space, will the db grow to 1TB in size?
> > >>
> > >
> >
>


Re: Storage limitations?

2013-11-09 Thread Mark Deibert
Ok I was assuming the db could be really big. I'm storing images so it
_will_ get pretty large.

For the field size question: I had an idea to greatly simplify
sorting/displaying a comments thread with replies by appending the replies
within their respective original comment field. Since the order I want to
display the comments is the natural chronological order, a simple append
process seems to make sense. Haven't tried yet but seems logical.


On Sat, Nov 9, 2013 at 11:32 AM, Robert Newson  wrote:

> while the default configuration has max_document_size as 4Gb, it would
> be very unwise to make a document anywhere near that large. Database
> size is limited only by disk capacity but note that you'll need some
> free space for compacting the database.
>
> On 9 November 2013 15:28, first-l...@yandex.ru 
> wrote:
> > Base size in no limit. But file system may be limit by file size.
> > Doc size limit is 4Gb. (one or two or more field: total - 4Gb)
> >
> >> I have two storage questions. How big can any one field in one doc be?
> >> Also, is there any limit on the size of a CouchDB? Meaning, if I have
> 1TB
> >> of free disk space, will the db grow to 1TB in size?
> >>
> >
>


Re: Storage limitations?

2013-11-09 Thread Robert Newson
while the default configuration has max_document_size as 4Gb, it would
be very unwise to make a document anywhere near that large. Database
size is limited only by disk capacity but note that you'll need some
free space for compacting the database.

On 9 November 2013 15:28, first-l...@yandex.ru  wrote:
> Base size in no limit. But file system may be limit by file size.
> Doc size limit is 4Gb. (one or two or more field: total - 4Gb)
>
>> I have two storage questions. How big can any one field in one doc be?
>> Also, is there any limit on the size of a CouchDB? Meaning, if I have 1TB
>> of free disk space, will the db grow to 1TB in size?
>>
>


Re: Database information from validate_doc_update

2013-11-09 Thread first-l...@yandex.ru

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
 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
 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: Storage limitations?

2013-11-09 Thread first-l...@yandex.ru

Base size in no limit. But file system may be limit by file size.
Doc size limit is 4Gb. (one or two or more field: total - 4Gb)

I have two storage questions. How big can any one field in one doc be?
Also, is there any limit on the size of a CouchDB? Meaning, if I have 1TB
of free disk space, will the db grow to 1TB in size?





Re: Database information from validate_doc_update

2013-11-09 Thread Alexander Shorin
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
 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
>>  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.
>
>


Storage limitations?

2013-11-09 Thread Mark Deibert
I have two storage questions. How big can any one field in one doc be?
Also, is there any limit on the size of a CouchDB? Meaning, if I have 1TB
of free disk space, will the db grow to 1TB in size?


Re: Database information from validate_doc_update

2013-11-09 Thread first-l...@yandex.ru

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  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 
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
 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

2013-11-09 Thread Robert Newson
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  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 
>> 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
  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

2013-11-09 Thread first-l...@yandex.ru

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  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
 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

2013-11-09 Thread Robert Newson
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  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
>>  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

2013-11-09 Thread first-l...@yandex.ru

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
 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.