CouchDB Library

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

pink
Posts: 272
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: 272
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: 272
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: 9801
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

pink
Posts: 272
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: 272
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: 9801
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

pink
Posts: 272
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: 272
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

albertucho
Posts: 3
Joined: Mon Aug 10, 2020 2:43 pm

Re: CouchDB Library

Post by albertucho » Fri Aug 21, 2020 11:30 am

Hi,

Any news about your CouchDB library?

Let me know if you have it in Git and licence model, please.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3975
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: CouchDB Library

Post by bn » Fri Aug 21, 2020 11:54 am

Hi Alberto,

have a look here

https://github.com/madpink/couchdb4livecode

Kind regards
Bernd

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

Re: CouchDB Library

Post by pink » Fri Aug 21, 2020 3:57 pm

Thanks for posting the link Bernd.

As an FYI - the current version of the library works with versions 2.0+ and 3.0+.
Greg (pink) Miller

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

stam
Posts: 2599
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: CouchDB Library

Post by stam » Sun Nov 08, 2020 7:02 pm

Thanks @pink,

Daybed library for couchDB looks very interesting... but my mindset is so SQL focused i keep thinking in terms of SQL approach which is probably not optimal for couchDB.
Is anyone able to share an actual working stack with CRUD operations in action, populating list boxes, related fields, updating etc with couchDB? (sorry, i know i shouldn't say 'related'). Reading the API kinda makes sense but i keep thinking in terms of relational databases...

Would be really great if someone could share a stack where either couchDB and/or Daybed were used 'in real life'

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

Re: CouchDB Library

Post by FourthWorld » Sun Nov 08, 2020 10:43 pm

Getting data in and out if a data store is the easy part. And I believe the examples provided at the repo handle that.

The harder part of deciding whether to use a relational store or a document store for a given project is understanding the modeling constraints of each.

There's a ton of comparisons out in the web, many entertainingly emotional. ;)

The most useful single article I've read in this sort of comparison is this one:
http://www.sarahmei.com/blog/2013/11/11 ... e-mongodb/

From the title she makes her preference extremely clear. But she also provides real-world examples of projects where a document store later proved not to be an ideal fit.

It was after reading her article that I dove into document stores head first, for projects where they're a good fit. Her arguments (though at times overly strong IMO) help us understand what makes for a good fit.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 2599
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: CouchDB Library

Post by stam » Mon Nov 09, 2020 2:06 am

FourthWorld wrote:
Sun Nov 08, 2020 10:43 pm
The most useful single article I've read in this sort of comparison is this one:
http://www.sarahmei.com/blog/2013/11/11 ... e-mongodb/
Thanks Richard - very interesting article and comment section was equally enlightening... i guess my projects are just not a good fit for document based DBs and that's why i can't get my head round this... maybe :)

Post Reply

Return to “Databases”