Re: Node.js client for CouchDB

2012-06-08 Thread Mark Hahn
>  The code that you modularized, rewrote and purged sync from

It's the jquery.couchdb.js library that is included in the couchdb
distribution.  It's not great code, but it is what futon uses.

>  What do you mean here?  "no benefit in my code

I discovered that because of security concerns I had to proxy db calls from
the browser through node.  Otherwise anyone could use the same library to
do anything they wanted to my couchdb.  If couchdb had a decent security
system this wouldn't be a problem.  Anyway, since I had to go through node
code anyway, it was cleaner to use nano from that code than to use my fake
jquery.  The proxy is a very small amount of clean code, thanks to nano's
simplicity.

>  I'm not sure if nano is offering authN or https

I wouldn't know.  I'm just using it on localhost.  I think one of the
advantages of couchdb is that it is easy to run a copy on every server and
use the replication to share data across servers.  So I always use
localhost.

On Fri, Jun 8, 2012 at 12:13 PM, Pulkit Singhal wrote:

> Ahoy Mark! Thank you so much for validating that I'm not the 1st person
> ever who thought of reusing futon.
>
> Some follow-up Qs:
>
> 1) The code that you modularized, rewrote and purged sync from ...Is it
> available on GitHub or somewhere else in the open source community by any
> chance?
>
> 2) What do you mean here?
> "no benefit in my code to having the same code run both places"
>
> 3) I'm not sure if nano is offering authN or https so I'm still looking
> into that. I had started out rolling my own non-re-usable solution by using
> Mikeal's request module but I wised up and am looking into Nano now. Slowly
> but surely. Cradle's next, thanks to all the folk who pointed it out.
>
> On Fri, Jun 8, 2012 at 12:25 PM, Mark Hahn  wrote:
>
> > > I find myself wondering why someone hasn't simply taken the javascript
> > code that
> > runs Futon and dropped it into a node.js module?
> >
> > I did something like that.  I wrote a module that was a clone of jQuery
> > that just implemented the ajax with http.requests.  Then I made minor
> mods
> > to the jquery code supplied with futon to make it a module.   So I was
> able
> > to write DB code that ran on the server and client with no mods.
> >
> > I found 3 reasons to not do this ...
> >
> > 1) The futon driver used a sync ajax call which was impossible to
> implement
> > in node.  I had to rewrite some of the code.  The person at microsoft who
> > decided to include an sync call should be shot, as well as the futon
> coder
> > who used it.
> >
> > 2) The futon driver used non-standard callback returns.  Different
> > callbacks were used for success and error.
> >
> > 3) I discovered there was no benefit in my code to having the same code
> run
> > both places.
> >
> > So I switched to nano.  I love nano. I'm using rpc's over socket.io to
> get
> > db access from browser.
> >
>


Re: Node.js client for CouchDB

2012-06-08 Thread Pulkit Singhal
Interesting comment about nodeup, so far I found one that has the nano
author:
http://nodeup.com/eleven

Any other podcasts that mention nano?

On Fri, Jun 8, 2012 at 11:25 AM, Morgan Craft  wrote:

> I haven't messed with couchdb much lately, but when I was experimenting
> with it and nodejs I was using the cradle library.  However, on the nodeup
> podcast everyone seems to recommend Nano as the preferred couchdb lib as of
> now.
>
> -m
>
>
>
> On Fri, Jun 8, 2012 at 12:21 PM, Pulkit Singhal  >wrote:
>
> > Hello Folks,
> >
> > What are some good node.js clients for communicating with CouchDB?
> >
> > If you are having trouble understanding why I would even want one then
> just
> > imagine that the app will not sit as a design document inside CouchDB but
> > rather be elsewhere and simply talking to CouchDB via the node.js client.
> > Or imagine that I'm doing TDD test driven development where I want to
> flesh
> > out the user-stories and workflow as nothing more than 10 or 12 calls to
> > CouchDB. Now I COULD do this via curl but parsing the output from
> previous
> > JSON responses in a big test driven workflow is not exactly a joyous or
> > successful task for me to accomplish.
> >
> > So far I've only found nano (https://github.com/dscape/nano) and I find
> > myself wondering why someone hasn't simply taken the javascript code that
> > runs Futon and dropped it into a node.js module? Has something like this
> > been done? Because that would (in my imaginary world) provide a full
> blown
> > client for use within node.js :)
> >
>


Re: Node.js client for CouchDB

2012-06-08 Thread Pulkit Singhal
Thanks Michel! Adding one more that noone's mentioned yet but I'll be very
curious if anyone else +1s it:
https://github.com/rsms/node-couchdb-min

On Fri, Jun 8, 2012 at 1:26 PM, Michel Legnered
wrote:

> https://github.com/felixge/node-couchdb
>
>
>
> On 8 jun 2012, at 18:21, Pulkit Singhal  wrote:
>
> > Hello Folks,
> >
> > What are some good node.js clients for communicating with CouchDB?
> >
> > If you are having trouble understanding why I would even want one then
> just
> > imagine that the app will not sit as a design document inside CouchDB but
> > rather be elsewhere and simply talking to CouchDB via the node.js client.
> > Or imagine that I'm doing TDD test driven development where I want to
> flesh
> > out the user-stories and workflow as nothing more than 10 or 12 calls to
> > CouchDB. Now I COULD do this via curl but parsing the output from
> previous
> > JSON responses in a big test driven workflow is not exactly a joyous or
> > successful task for me to accomplish.
> >
> > So far I've only found nano (https://github.com/dscape/nano) and I find
> > myself wondering why someone hasn't simply taken the javascript code that
> > runs Futon and dropped it into a node.js module? Has something like this
> > been done? Because that would (in my imaginary world) provide a full
> blown
> > client for use within node.js :)
>


Re: Node.js client for CouchDB

2012-06-08 Thread Pulkit Singhal
Ahoy Mark! Thank you so much for validating that I'm not the 1st person
ever who thought of reusing futon.

Some follow-up Qs:

1) The code that you modularized, rewrote and purged sync from ...Is it
available on GitHub or somewhere else in the open source community by any
chance?

2) What do you mean here?
"no benefit in my code to having the same code run both places"

3) I'm not sure if nano is offering authN or https so I'm still looking
into that. I had started out rolling my own non-re-usable solution by using
Mikeal's request module but I wised up and am looking into Nano now. Slowly
but surely. Cradle's next, thanks to all the folk who pointed it out.

On Fri, Jun 8, 2012 at 12:25 PM, Mark Hahn  wrote:

> > I find myself wondering why someone hasn't simply taken the javascript
> code that
> runs Futon and dropped it into a node.js module?
>
> I did something like that.  I wrote a module that was a clone of jQuery
> that just implemented the ajax with http.requests.  Then I made minor mods
> to the jquery code supplied with futon to make it a module.   So I was able
> to write DB code that ran on the server and client with no mods.
>
> I found 3 reasons to not do this ...
>
> 1) The futon driver used a sync ajax call which was impossible to implement
> in node.  I had to rewrite some of the code.  The person at microsoft who
> decided to include an sync call should be shot, as well as the futon coder
> who used it.
>
> 2) The futon driver used non-standard callback returns.  Different
> callbacks were used for success and error.
>
> 3) I discovered there was no benefit in my code to having the same code run
> both places.
>
> So I switched to nano.  I love nano. I'm using rpc's over socket.io to get
> db access from browser.
>


Re: Node.js client for CouchDB

2012-06-08 Thread Michael Aufreiter
I've adapted Tim Caswell's minimal CouchClient and use it on Substance.io.  

Here's the lib and the documentation:

https://github.com/michael/couch-client
http://substance.io/michael/couch-client

Cheers,

Michael  


http://mapbox.com · http://substance.io · http://quasipartikel.at



On Friday, June 8, 2012 at 2:26 PM, Michel Legnered wrote:

> https://github.com/felixge/node-couchdb
>  
>  
>  
> On 8 jun 2012, at 18:21, Pulkit Singhal  (mailto:pulkitsing...@gmail.com)> wrote:
>  
> > Hello Folks,
> >  
> > What are some good node.js clients for communicating with CouchDB?
> >  
> > If you are having trouble understanding why I would even want one then just
> > imagine that the app will not sit as a design document inside CouchDB but
> > rather be elsewhere and simply talking to CouchDB via the node.js client.
> > Or imagine that I'm doing TDD test driven development where I want to flesh
> > out the user-stories and workflow as nothing more than 10 or 12 calls to
> > CouchDB. Now I COULD do this via curl but parsing the output from previous
> > JSON responses in a big test driven workflow is not exactly a joyous or
> > successful task for me to accomplish.
> >  
> > So far I've only found nano (https://github.com/dscape/nano) and I find
> > myself wondering why someone hasn't simply taken the javascript code that
> > runs Futon and dropped it into a node.js module? Has something like this
> > been done? Because that would (in my imaginary world) provide a full blown
> > client for use within node.js :)
>  





Re: Node.js client for CouchDB

2012-06-08 Thread Michel Legnered
https://github.com/felixge/node-couchdb



On 8 jun 2012, at 18:21, Pulkit Singhal  wrote:

> Hello Folks,
> 
> What are some good node.js clients for communicating with CouchDB?
> 
> If you are having trouble understanding why I would even want one then just
> imagine that the app will not sit as a design document inside CouchDB but
> rather be elsewhere and simply talking to CouchDB via the node.js client.
> Or imagine that I'm doing TDD test driven development where I want to flesh
> out the user-stories and workflow as nothing more than 10 or 12 calls to
> CouchDB. Now I COULD do this via curl but parsing the output from previous
> JSON responses in a big test driven workflow is not exactly a joyous or
> successful task for me to accomplish.
> 
> So far I've only found nano (https://github.com/dscape/nano) and I find
> myself wondering why someone hasn't simply taken the javascript code that
> runs Futon and dropped it into a node.js module? Has something like this
> been done? Because that would (in my imaginary world) provide a full blown
> client for use within node.js :)


Re: Node.js client for CouchDB

2012-06-08 Thread Quang Van
Any good Nano vs Cradle comparisons?

I'm using cradle right now... and if a lot of people is recommending Nano
over cradle, I wonder why...

Thanks.

On Fri, Jun 8, 2012 at 1:25 PM, Mark Hahn  wrote:

> > I find myself wondering why someone hasn't simply taken the javascript
> code that
> runs Futon and dropped it into a node.js module?
>
> I did something like that.  I wrote a module that was a clone of jQuery
> that just implemented the ajax with http.requests.  Then I made minor mods
> to the jquery code supplied with futon to make it a module.   So I was able
> to write DB code that ran on the server and client with no mods.
>
> I found 3 reasons to not do this ...
>
> 1) The futon driver used a sync ajax call which was impossible to implement
> in node.  I had to rewrite some of the code.  The person at microsoft who
> decided to include an sync call should be shot, as well as the futon coder
> who used it.
>
> 2) The futon driver used non-standard callback returns.  Different
> callbacks were used for success and error.
>
> 3) I discovered there was no benefit in my code to having the same code run
> both places.
>
> So I switched to nano.  I love nano. I'm using rpc's over socket.io to get
> db access from browser.
>


Re: Node.js client for CouchDB

2012-06-08 Thread Mark Hahn
> I find myself wondering why someone hasn't simply taken the javascript
code that
runs Futon and dropped it into a node.js module?

I did something like that.  I wrote a module that was a clone of jQuery
that just implemented the ajax with http.requests.  Then I made minor mods
to the jquery code supplied with futon to make it a module.   So I was able
to write DB code that ran on the server and client with no mods.

I found 3 reasons to not do this ...

1) The futon driver used a sync ajax call which was impossible to implement
in node.  I had to rewrite some of the code.  The person at microsoft who
decided to include an sync call should be shot, as well as the futon coder
who used it.

2) The futon driver used non-standard callback returns.  Different
callbacks were used for success and error.

3) I discovered there was no benefit in my code to having the same code run
both places.

So I switched to nano.  I love nano. I'm using rpc's over socket.io to get
db access from browser.


Re: Node.js client for CouchDB

2012-06-08 Thread Morgan Craft
To my understanding Nano is just a light wrapper around Mikeal's request,
I've yet to use Nano, but I use Mikeal's request for various projects.

I had nothing against cradle and at the time it was the only lib.



On Fri, Jun 8, 2012 at 12:43 PM, Sam Bisbee  wrote:

> Nano is the most popular, cradle seems to be less popular, and
> saggingcouch.com gives you JS in browser and node with a mirrored API in
> PHP (I wrote sag so am biased).
>
> Or just use a straight HTTP lib like Mikeal's request.
>
> Cheers,
>
> --
> Sam Bisbee
> Sent from my phone so please excuse brevity and typos.
> On Jun 8, 2012 9:21 AM, "Pulkit Singhal"  wrote:
>
> > Hello Folks,
> >
> > What are some good node.js clients for communicating with CouchDB?
> >
> > If you are having trouble understanding why I would even want one then
> just
> > imagine that the app will not sit as a design document inside CouchDB but
> > rather be elsewhere and simply talking to CouchDB via the node.js client.
> > Or imagine that I'm doing TDD test driven development where I want to
> flesh
> > out the user-stories and workflow as nothing more than 10 or 12 calls to
> > CouchDB. Now I COULD do this via curl but parsing the output from
> previous
> > JSON responses in a big test driven workflow is not exactly a joyous or
> > successful task for me to accomplish.
> >
> > So far I've only found nano (https://github.com/dscape/nano) and I find
> > myself wondering why someone hasn't simply taken the javascript code that
> > runs Futon and dropped it into a node.js module? Has something like this
> > been done? Because that would (in my imaginary world) provide a full
> blown
> > client for use within node.js :)
> >
>


Re: Node.js client for CouchDB

2012-06-08 Thread Sam Bisbee
Nano is the most popular, cradle seems to be less popular, and
saggingcouch.com gives you JS in browser and node with a mirrored API in
PHP (I wrote sag so am biased).

Or just use a straight HTTP lib like Mikeal's request.

Cheers,

--
Sam Bisbee
Sent from my phone so please excuse brevity and typos.
On Jun 8, 2012 9:21 AM, "Pulkit Singhal"  wrote:

> Hello Folks,
>
> What are some good node.js clients for communicating with CouchDB?
>
> If you are having trouble understanding why I would even want one then just
> imagine that the app will not sit as a design document inside CouchDB but
> rather be elsewhere and simply talking to CouchDB via the node.js client.
> Or imagine that I'm doing TDD test driven development where I want to flesh
> out the user-stories and workflow as nothing more than 10 or 12 calls to
> CouchDB. Now I COULD do this via curl but parsing the output from previous
> JSON responses in a big test driven workflow is not exactly a joyous or
> successful task for me to accomplish.
>
> So far I've only found nano (https://github.com/dscape/nano) and I find
> myself wondering why someone hasn't simply taken the javascript code that
> runs Futon and dropped it into a node.js module? Has something like this
> been done? Because that would (in my imaginary world) provide a full blown
> client for use within node.js :)
>


Re: Node.js client for CouchDB

2012-06-08 Thread Stephan Bardubitzki

+1 for cradle


On 12-06-08 09:25 AM, Morgan Craft wrote:

I haven't messed with couchdb much lately, but when I was experimenting
with it and nodejs I was using the cradle library.  However, on the nodeup
podcast everyone seems to recommend Nano as the preferred couchdb lib as of
now.

-m



On Fri, Jun 8, 2012 at 12:21 PM, Pulkit Singhalwrote:


Hello Folks,

What are some good node.js clients for communicating with CouchDB?

If you are having trouble understanding why I would even want one then just
imagine that the app will not sit as a design document inside CouchDB but
rather be elsewhere and simply talking to CouchDB via the node.js client.
Or imagine that I'm doing TDD test driven development where I want to flesh
out the user-stories and workflow as nothing more than 10 or 12 calls to
CouchDB. Now I COULD do this via curl but parsing the output from previous
JSON responses in a big test driven workflow is not exactly a joyous or
successful task for me to accomplish.

So far I've only found nano (https://github.com/dscape/nano) and I find
myself wondering why someone hasn't simply taken the javascript code that
runs Futon and dropped it into a node.js module? Has something like this
been done? Because that would (in my imaginary world) provide a full blown
client for use within node.js :)



Spam/Virus scanning by CanIt Pro

For more information see
http://www.kgbinternet.com/SpamFilter.htm

To control your spam filter, log in at
http://filter.kgbinternet.com



Re: Node.js client for CouchDB

2012-06-08 Thread Morgan Craft
I haven't messed with couchdb much lately, but when I was experimenting
with it and nodejs I was using the cradle library.  However, on the nodeup
podcast everyone seems to recommend Nano as the preferred couchdb lib as of
now.

-m



On Fri, Jun 8, 2012 at 12:21 PM, Pulkit Singhal wrote:

> Hello Folks,
>
> What are some good node.js clients for communicating with CouchDB?
>
> If you are having trouble understanding why I would even want one then just
> imagine that the app will not sit as a design document inside CouchDB but
> rather be elsewhere and simply talking to CouchDB via the node.js client.
> Or imagine that I'm doing TDD test driven development where I want to flesh
> out the user-stories and workflow as nothing more than 10 or 12 calls to
> CouchDB. Now I COULD do this via curl but parsing the output from previous
> JSON responses in a big test driven workflow is not exactly a joyous or
> successful task for me to accomplish.
>
> So far I've only found nano (https://github.com/dscape/nano) and I find
> myself wondering why someone hasn't simply taken the javascript code that
> runs Futon and dropped it into a node.js module? Has something like this
> been done? Because that would (in my imaginary world) provide a full blown
> client for use within node.js :)
>


Node.js client for CouchDB

2012-06-08 Thread Pulkit Singhal
Hello Folks,

What are some good node.js clients for communicating with CouchDB?

If you are having trouble understanding why I would even want one then just
imagine that the app will not sit as a design document inside CouchDB but
rather be elsewhere and simply talking to CouchDB via the node.js client.
Or imagine that I'm doing TDD test driven development where I want to flesh
out the user-stories and workflow as nothing more than 10 or 12 calls to
CouchDB. Now I COULD do this via curl but parsing the output from previous
JSON responses in a big test driven workflow is not exactly a joyous or
successful task for me to accomplish.

So far I've only found nano (https://github.com/dscape/nano) and I find
myself wondering why someone hasn't simply taken the javascript code that
runs Futon and dropped it into a node.js module? Has something like this
been done? Because that would (in my imaginary world) provide a full blown
client for use within node.js :)


JSON structure for security object

2012-06-08 Thread Pulkit Singhal
Has the JSON structure for security object changed in version 1.2.0 to use
the members key instead of readers key?

I ask because the Futon pop-up for the setting the security of a database,
changed its terminology from "readers" to "members" and I find myself
wondering if its a cosmetic change or something more.

I know that at least the current info on the CouchDB wiki doesn't show any
such change but it doesn't hurt to confirm :)
http://wiki.apache.org/couchdb/Security_Features_Overview#Authorization
{
  "admins" : {
 "names" : ["joe", "phil"],
 "roles" : ["boss"]
   },
   "readers" : {
 "names" : ["dave"],
 "roles" : ["producer", "consumer"]
   }
}


Re: Adding vs replicating documents

2012-06-08 Thread Jens Alfke

On Jun 7, 2012, at 8:12 PM, Luca Matteis wrote:

> Ok basically I have a program that runs on my local computer that
> generates data that I want to insert/modify to my Couch instance. So
> my local data should be in synch with my cloud data... but i can't
> install CouchDB locally... so how do I keep it in synch with my hosted
> Couch instance without having to re-upload all of my data every time?

For each record in the local file, decide whether it's different from what's in 
CouchDB. If it is, PUT the document to the database.

How to tell whether it's different depends on what's in your file. If you have 
timestamps it's pretty easy. Otherwise you may have to do something like 
storing a local side file with checksums of every document, and then comparing 
the values in the file against the saved checksums. The checksum file can also 
store the rev ID from the last time you saved to CouchDB, which will make 
saving easier.

—Jens

Re: result from _bulk_docs update being truncated

2012-06-08 Thread Tim Tisdall
Okay...  For the moment I'm going to try the following change:

while(!feof($s)) {
//$response .= fgets($s);
$response .= fread($s, 8192);
}

fgets() is intended to fetch results up until the line ending, which
don't think makes a lot of sense when the result (I think) never has
any line endings.  fread() simply reads the number of bytes indicated
in a binary-safe way.

-Tim

On Fri, Jun 8, 2012 at 9:55 AM, Dave Cottlehuber  wrote:
> On 8 June 2012 15:47, Tim Tisdall  wrote:
>> I'm having a strange intermittent problem where the result returned
>> from a POST to _bulk_docs is being truncated.  I know it's being
>> truncated because the truncation makes the result invalid JSON and my
>> script throws an exception because it can't decode it.  However, I
>> can't replicate it consistently and it seems rather random.  I'm using
>> code nearly identical to CouchSimple on the wiki at
>> http://wiki.apache.org/couchdb/Getting_started_with_PHP#What_Does_it_Do.3F
>> .
>>
>> Right now it's consistently truncating after 65734 characters, but I
>> saw this occurring in another script at around 2^15 bytes.  I suspect
>> there's something awry with PHP's fsockopen, but I'm hoping someone
>> here has seen this and found a solution or work-around.
>>
>> -Tim
>
> The std method for tracking these down is to insert a proxy or packet sniffer 
> in
> between Couch and the library. Charles Proxy is very nice, feel free to select
> something else.
>
> A+
> Dave


Re: result from _bulk_docs update being truncated

2012-06-08 Thread Dave Cottlehuber
On 8 June 2012 15:55, Dave Cottlehuber  wrote:
> On 8 June 2012 15:47, Tim Tisdall  wrote:
>> I'm having a strange intermittent problem where the result returned
>> from a POST to _bulk_docs is being truncated.  I know it's being
>> truncated because the truncation makes the result invalid JSON and my
>> script throws an exception because it can't decode it.  However, I
>> can't replicate it consistently and it seems rather random.  I'm using
>> code nearly identical to CouchSimple on the wiki at
>> http://wiki.apache.org/couchdb/Getting_started_with_PHP#What_Does_it_Do.3F
>> .
>>
>> Right now it's consistently truncating after 65734 characters, but I
>> saw this occurring in another script at around 2^15 bytes.  I suspect
>> there's something awry with PHP's fsockopen, but I'm hoping someone
>> here has seen this and found a solution or work-around.
>>
>> -Tim
>
> The std method for tracking these down is to insert a proxy or packet sniffer 
> in
> between Couch and the library. Charles Proxy is very nice, feel free to select
> something else.

Sorry, too fast.

"and check to see that all the JSON data actually gets emitted from
the client side".

Good luck!


Re: result from _bulk_docs update being truncated

2012-06-08 Thread Dave Cottlehuber
On 8 June 2012 15:47, Tim Tisdall  wrote:
> I'm having a strange intermittent problem where the result returned
> from a POST to _bulk_docs is being truncated.  I know it's being
> truncated because the truncation makes the result invalid JSON and my
> script throws an exception because it can't decode it.  However, I
> can't replicate it consistently and it seems rather random.  I'm using
> code nearly identical to CouchSimple on the wiki at
> http://wiki.apache.org/couchdb/Getting_started_with_PHP#What_Does_it_Do.3F
> .
>
> Right now it's consistently truncating after 65734 characters, but I
> saw this occurring in another script at around 2^15 bytes.  I suspect
> there's something awry with PHP's fsockopen, but I'm hoping someone
> here has seen this and found a solution or work-around.
>
> -Tim

The std method for tracking these down is to insert a proxy or packet sniffer in
between Couch and the library. Charles Proxy is very nice, feel free to select
something else.

A+
Dave


Re: Adding vs replicating documents

2012-06-08 Thread Tim Tisdall
I was going to suggest something like this too.  However, if you have
access to the script, you could alter it to record in a separate file
which documents have been altered and then write another script to
only send those docs to the couchdb server.  (This is essentially
duplicating what the couchdb replication would do, but without having
to have couchdb on your local machine)  A really simple way is to just
output the doc ids you've modified to a text file and then wipe that
file out after you've sent the updates to the server.

On Fri, Jun 8, 2012 at 2:10 AM, Matthieu Rakotojaona
 wrote:
> I guess you can write some script that makes a diff between the old
> version and the new version, and returns the changed docs. You could
> then upload only those changed docs.
>
> --
> Matthieu RAKOTOJAONA


result from _bulk_docs update being truncated

2012-06-08 Thread Tim Tisdall
I'm having a strange intermittent problem where the result returned
from a POST to _bulk_docs is being truncated.  I know it's being
truncated because the truncation makes the result invalid JSON and my
script throws an exception because it can't decode it.  However, I
can't replicate it consistently and it seems rather random.  I'm using
code nearly identical to CouchSimple on the wiki at
http://wiki.apache.org/couchdb/Getting_started_with_PHP#What_Does_it_Do.3F
.

Right now it's consistently truncating after 65734 characters, but I
saw this occurring in another script at around 2^15 bytes.  I suspect
there's something awry with PHP's fsockopen, but I'm hoping someone
here has seen this and found a solution or work-around.

-Tim


Re: Migrate htpasswd users to _users?

2012-06-08 Thread Keith Gable
Well what I'm trying to say is crypt() won't work. You'll have to use the
APR-specific crypt() or a clone implementation. I remember seeing one in
Python on the nginx wiki.
On Jun 7, 2012 10:48 PM, "Jim Klo"  wrote:

> As we're using whatever the default is on Ubuntu (which is crypt() per
> manpage http://linux.die.net/man/1/htpasswd)
>
> Is there an existing authentication handler plugin that uses crypt? While
> I'm not even close to even call myself an Erlang noob - from here it
> doesn't seem like it would too difficult to alter
> https://github.com/apache/couchdb/blob/1.2.x/src/couchdb/couch_httpd_auth.erlbut
>  have no idea  where to start on modifying as a plugin.
>
> Worst case I just make all my users reset their passwords.
>
> - Jim
>
>
> Sent from my iPad
>
> On Jun 7, 2012, at 7:12 PM, "Keith Gable" 
> wrote:
>
> > htpasswd supports several different hash schemes. $apr1$ is the default
> and
> > isn't very portable (though is supported by nginx) because it's not
> exactly
> > MD5 as generated by crypt().
> > On Jun 7, 2012 4:15 PM, "Jim Klo"  wrote:
> >
> >> Wondering if there is a way to easily migrate a flat file of htpasswd
> >> users into couchdb _users?
> >>
> >> htpasswd typically uses crypt() which I think i based off a MD5, and
> >> couchdb uses SHA1.
> >>
> >> So essentially is there a stable authentication handler out there that
> >> replicates htpasswd?
> >>
> >> Thanks,
> >>
> >> - Jim
> >>
> >> *
> >> Jim Klo
> >> Senior Software Engineer
> >> Center for Software Engineering
> >> SRI International
> >> *
> >>
> >>
>


Re: Efficient way to identify documents

2012-06-08 Thread Simon Metson
Hi,  
You're better off emitting all the docs regardless of type and then using 
start_key/end_key to get the docs you're interested in:

function(doc){
  emit(doc._id, null);
}

then query the view with ?startkey="T1_"&endkey="T2_"

If your also interested in the number of docs per T1, T2 etc… You could do:

function(doc){
  emit(doc._id.substr(0,3), 1);
}


and use a _sum or _count reduce function to count the docs.
HTH
Simon


On Friday, 8 June 2012 at 08:18, Paulo Carvalho wrote:

> Hello,
>  
> Most of the functionnalities of the application using this database are 
> listing functionnalities. This is the main reason why in my couchDB structure 
> I have put T2's information inside T1's documents.
>  
> So, it is necessary for me to have such structure to improve listing 
> functions performance.
>  
> This is why I am looking (if existant) a better way that the one I am using 
> to identify all T1 documents, etc.
>  
> e.g. function to get all the T1 documents:
> function(doc) { if(doc._id.indexOf('T1_') == 0) { emit(null, doc); } }Thank 
> you
>  
> Regards
>  
> On Thu, Jun 7, 2012 at 11:00 PM, Simon Metson  (mailto:si...@cloudant.com)> wrote:
> > Hey Paulo,  
> > I think you need to think about what data you have and how you want to 
> > interrogate it, rather than how you currently structure your database 
> > schema; it sounds like you have a very normalised schema and you need to 
> > denormalise that to make the most of CouchDB.
> >  
> > By moving to a NoSQL DB you need to review your use cases and requirements 
> > and change how you think about the data. It might not be that the tradeoffs 
> > you need to make don't fit your data, or that you have no choice but to 
> > change your data model to adopt a tool that has the features you need.  
> > Cheers
> > Simon
> >  
> > On Thursday, 7 June 2012 at 15:02, Paulo Carvalho wrote:
> >  
> > > Hello,
> > >  
> > > Thanks for your answer.
> > >  
> > > However, I don't know if the proposed solution works for my purpose 
> > > because I have several tables more (so, much more documents).
> > >  
> > > Before, in my relational database, I had several tables, to simplify, I 
> > > will call them T1, T2, T3, T4, T5, ..., TN
> > >  
> > > Now, in the couchDB database, I have a structure like that:
> > >  
> > > {
> > >   _id = T1_1
> > >   T2 {
> > >  ...
> > >   }
> > > {
> > >   _id = T1_2
> > >  T2 {
> > >  ...
> > >   }
> > > }
> > >  
> > > {
> > >   _id = T1_3
> > >  T2 {
> > >  ...
> > >   }
> > >  T3 {
> > >  ...
> > >   }
> > > }
> > >  
> > > {
> > >   _id = T2_1
> > >  ...
> > > }
> > >  
> > >  
> > > {
> > >   _id = T2_2
> > >  ...
> > > }
> > >  
> > >  
> > > {
> > >   _id = T2_3
> > >  ...
> > > }
> > >  
> > > {
> > >   _id = T2_3
> > >   T5 {
> > > ...
> > >   }
> > >   ...
> > > }
> > >  
> > > }
> > >  
> > >  
> > > As you can see, in the "root" level of the DB, I can have documents which 
> > > are "instances" of different tables.
> > >  
> > > What I would like to do, is to find the most performant way to list all 
> > > the documents which come from T1 table, all the documents which come from 
> > > T2 table, etc.
> > >  
> > > Do you understood my doubt?
> > >  
> > > Thank you
> > >  
> > > Best regards
> > >  
> > > Paulo
> > >  
> > >  
> > > On Thu, Jun 7, 2012 at 3:38 PM, Simon Metson  > > (mailto:si...@cloudant.com)> wrote:
> > > > Hi,  
> > > > Moving this to user@
> > > >  
> > > > If you just need the authors names, and books are unique, you could 
> > > > just have your book documents be something like:
> > > >  
> > > > {  
> > > >   _id: book_title,
> > > >   author: {
> > > > name: author_name,
> > > > age: author_age
> > > >   },
> > > >   year: book_year
> > > > }
> > > >  
> > > > then pull out all the authors via a view.   
> > > >  
> > > > You shouldn't include the doc in the view value, that's very space 
> > > > inefficient. I think you'll want a view like:
> > > >  
> > > > // view for books
> > > > function(doc) {
> > > >   emit(doc._id, 1);
> > > > }
> > > >  
> > > >  
> > > > //view for authors
> > > > function(doc) {
> > > >   emit(doc.author.name (http://doc.author.name), 1);
> > > > }
> > > >  
> > > >  
> > > > (you could use a _count reduce to return the number of books/authors, 
> > > > if thats useful)
> > > >  
> > > > The above depends a lot on what you want to use the data for, and what 
> > > > other information you need to include in your docs, though. You might 
> > > > need to have a list of authors, for example, or include their biography 
> > > > in which case the above isn't great.  
> > > > Cheers
> > > > Simon
> > > >  
> > > > On Thursday, 7 June 2012 at 13:57, pjmorce wrote:
> > > > > Hello,
> > > > >  
> > > > > I am new to noSQL databases and more precisely to couchDB.
> > > > >  
> > > > > I have migrated my PostgreSQL database to couchDB.
> > > > >  
> > > > > Before, in my relational database I had 2 tables: Authors and Books
> > > > >  
> > > > > 

Re: Adding vs replicating documents

2012-06-08 Thread Dave Cottlehuber
On 8 June 2012 06:26, Luca Matteis  wrote:

> Ok, say I install a local Couch that I upload my 1gb of data to.
> Whenever a change is made to a JSON document in my file, my routine
> will still have to go through all the records and update my local
> Couch, which would result in the entire DB updating, therefore the
> replication would need to transfer *everything* to my hosted Couch
> once again.
>
>
Continuous replication would be an obvious solution to this.

If you need to intervene programmatically then sit on the _changes feed,
keep track of the ids that change and then specify the URLs to replicate
manually. This is covered on the wiki & in the guide also, you have the
links
by now  :-)

If your JSON docs are generated by script with ids, then you can simply
regenerate them into your local couch (no need for replication) and
the revs etc will all match up nicely with the remote end.

Key misconceptions:

#1 changes feed will allow you to find out changes since a given DB update.

#2 replication does not transfer all documents, it compares docs and
missing revs
and makes smart decisions on what needs to be transferred. If a doc exists
in the source but not in the destination, the whole of that doc *does* of
course
need to be transferred. That's likely a simplistic summary but will do for
the
moment.

A+
Dave