CouchDB Library

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

pink
Posts: 252
Joined: Wed Mar 12, 2014 6:18 pm

Re: CouchDB Library

Post by pink » Mon Oct 26, 2015 4:22 pm

Status update:

Spent some time working and testing over the weekend.

I created a document in the repo called "couchAPIexamples", wherein I copied the main list of CouchDB API calls. As I tested each type of call, I pasted my code (if successful). The things that I haven't tested yet are items I really haven't used before.

I have tested getting, putting and posting documents to CouchDB extensively for the last few months, and since this is what I imagine most people need, you should be good to go.

Design documents and views are now working, you can both put and get them. Unless you have a static "design document" that you want to put into all new databases, or something similar, I would just use Futon to create them.

TO TEST:
-sessions (cookie based authentication, I have been using basic authentication thus far)
-config (never really had a need for it, so I haven't tested it yet)
-replication (to be honest, i find using Futon much easier for this)
-db/_local functions (need replication to be in effect first)
-a few other scattered functions

TO DO:
-attachments
-more design document functions (show/list/update)
-better documentation of how things work
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

pink
Posts: 252
Joined: Wed Mar 12, 2014 6:18 pm

Re: CouchDB Library

Post by pink » Mon Feb 01, 2016 9:43 pm

Progress has been slow but I've updated this library. I've made a few tweaks and attempted to create better API documentation.
I also added a separate function for adding new users, which is where things got tricky. Technically, a user is just a record with a specific format in the "_users" database.
The problem I had, is that a certain key (roles) need a value in the format of an array, even if it is blank or has only a single value.
This didn't seem possible using EasyJSON nor FastJSON, so I construct the JSON manually in syntax.

TO TEST:
-sessions (cookie based authentication, I have been using basic authentication thus far)
-replication (to be honest, i find using Futon much easier for this)
-db/_local functions (need replication to be in effect first)

TO DO:
-attachments
-more design document functions (show/list/update)
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

pink
Posts: 252
Joined: Wed Mar 12, 2014 6:18 pm

Re: CouchDB Library

Post by pink » Tue Apr 05, 2016 2:18 am

another major update has been pushed to github

the theme of this revision is "Security and Authentication"


-Added a new command for setting security on databases
-Revised the add user command, it will optionally create a database for the user and set security on it so only that user can access it
-Added a function to calculate the database name for a username created by the above function
-Added a function to calculate the database name for the couchperuser daemon. (Recommend using my new adduser command instead though)
-Added cookie based authentication functions
-Added a shortcut to arrayToJson/JsonToArray functions that corrects for an issue with JSON libraries that can't correctly handle empty arrays.

TO DO:
-replication functions
-db/_local functions
-attachments (need to add putting... getting is easy)
-design docs: show
-design docs: list
-design docs: update
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7314
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: CouchDB Library

Post by FourthWorld » Wed Apr 06, 2016 12:10 am

Thanks for your continued good work on this, Greg.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

pink
Posts: 252
Joined: Wed Mar 12, 2014 6:18 pm

Re: CouchDB Library

Post by pink » Wed Apr 06, 2016 2:40 am

Made a few more revisions and tests to include replication functions, _local docs (non-replicating documents in a database), temp_view and a few other functions.

Below is the final list of functions that need to be implemented and tested to cover the entire CouchDB API (and officially allow me to call it 1.0)

TO DO LIST:
-doc attachments (put, delete)
-design docs (delete)
-design docs: show (get,post)
-design docs: show on doc (get,post)
-design docs: list (get, post)
-design docs: list from other doc (get, post)
-design docs: rewrite (?)
-design docs: update (put)
-design docs: view (post)
-design docs: attachments (get, put delete)
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

pink
Posts: 252
Joined: Wed Mar 12, 2014 6:18 pm

Re: CouchDB Library

Post by pink » Fri Apr 08, 2016 1:21 am

pushed another update, added the rest of the design doc framework and the delete attachment functions

There is only one thing on my to do list which I cannot do which is upload attachments, the equivalent of this:

Code: Select all

curl -X PUT http://couch.mad.pink/test_suite_db2/zxsd3324d/bad_luck_friday13.jpg?rev=12-f5f9f6f0af4cb1f113c9794a10daf5bd \
    --data-binary /User/pink/Dropbox/bad_luck_friday13.jpg \
    -H "Cookie: AuthSession=cm9vdDo1NzA0NUVDRTovU5Y6gklEjt27Rn53KlC8TDQ4KQ" \
    -H "Content-Type: image/jpg"
For the time being, the library can handle the rest of the CouchDB API, and I am going to move on to the toolbox stack and some other fun functions.
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7314
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: CouchDB Library

Post by FourthWorld » Sat Apr 09, 2016 9:01 pm

I was looking over your lib, and I just wanted to thank you for naming the first arg pFunk. :) If I get some time this afternoon I'll install CouchDB and your lib, and fire up Funkentelechy Vs. the Placebo Syndrome in my headphones....
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

pink
Posts: 252
Joined: Wed Mar 12, 2014 6:18 pm

Re: CouchDB Library

Post by pink » Sat Apr 09, 2016 11:14 pm

FourthWorld wrote:I was looking over your lib, and I just wanted to thank you for naming the first arg pFunk. :) If I get some time this afternoon I'll install CouchDB and your lib, and fire up Funkentelechy Vs. the Placebo Syndrome in my headphones....
I do find it difficult to use the library and not start humming "GIve up the Funk"

I'll be pushing an update this weekend which will finally include attachments.

There are two methods for adding attachments via API in CouchDB, inline and standalone.

The standalone attachments are what I've been trying to do, and cannot actually accomplish.

Inline attachments basically is just a base64encoded version of the file inserted into the JSON. The drawback is that in order to add additional attachments, you need to download and the reupload the entire record with all attachments. It can be very inefficient for anyone dealing with lots of attachments on a single doc, but right now that's what I got.
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

pink
Posts: 252
Joined: Wed Mar 12, 2014 6:18 pm

Re: CouchDB Library

Post by pink » Mon Apr 11, 2016 12:36 am

Alrighty, contrary to what I said in my previous post, I was able to implement both methods of adding attachments.

That means, that as of now the entire CouchDB API is working in my library. (YAY!)
These functions are all prefixed with "couch."
I'm still going to do a bunch of testing to make sure that nothing else broke while I was getting everything in.

I've started adding some new functions that are prefixed with "dbdb" (for DaybedDB).

The first set of new functions are related to creating a save file with default URL and login information.

Next on my list is creating a stack based local database that syncs.
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

Post Reply

Return to “Databases”