Contents
Downloads
2What can I do with it?
This is a LiveCode library that can be used to build CouchDB queries with less coding effort spent.
Supported Features
- connect to couchdb
- Query _all_docs
- Query custom _views
- Create, get, update, delete documents
- Add, get, delete attachments
License
- Community: GPL
Tested with
- LiveCode 7
Download
- Community: Download on GitHub
Method Reference
See reference
Loading the libraries
In your stack file in the “on openStack” message add following lines of code:
on openStack
local tStackfiles
put "lcLibJson,lib/lcLibJson.livecode" & cr into tStackfiles
put "lcCouchQueryBuilder,lib/lcCouchQueryBuilder.livecode" after tStackFiles
set the stackfiles of this stack to tStackfiles
start using stack "lcLibJson"
start using stack "lcCouchQueryBuilder"
end openStack
This will load both libraries in to your stack file when you open the stack.
Example
on mouseUp
local tCouchConfig, tResult, tDoc, tUpdateDoc
put empty into tCouchConfig
put "http://127.0.0.1:5984/testdb" into tCouchConfig["url"]
put couchInit(tCouchConfig["url"]) into tResult
put empty into tDoc
put "James" into tDoc["firstname"]
put "Jameson" into tDoc["lastname"]
put "Blastreet 557" into tDoc["street"]
put "889966" into tDoc["zipcode"]
put "Far away" into tDoc["city"]
-- create
put couchCreateDocument(tDoc) into tResult
-- get
put couchGetDocument(tResult["id"]) into tResult
-- update
put tResult into tUpdateDoc
put "Other planet" into tUpdateDoc["country"]
put couchUpdateDocument(tUpdateDoc["_id"], tUpdateDoc["_rev"], tUpdateDoc) into tResult
-- delete
put couchDeleteDocument(tResult["id"], tResult["rev"]) into tResult
-- query view
put couchQueryView("testdb", "testview") into tResult
-- query all docs
put couchQueryAllDocs() into tResult
end mouseUp