![]() We first need to convert the fields into a JSON string and then to POST the JSON string into the deadbase. This is a very light install and is only lightly documented.Īssume we have a RUBY object (call it “rec”) which includes, among other things the fields we want to POST into the deadbase as a deadbase document like the one developed above. REST-OPEN-URI: This extends open-uri by using the net/http and the uri GEMs to cover all of the REST verbs (GET, POST, PUT and DELETE). For our purposes the ‘pure’ version is not necessary. a C based module you will need to have the Ruby/Windows DEVKit installed on your system. JSON : This will always load the Ruby based version of the JSON module. Here’s a minimum of what we need to POST a document to a couchdb using RUBY. There are several ActiveRecord type GEMS which will interface with couchDB but my focus here will be on: (1) speed of access and (2) transferability of knowledge between Ruby access and direct Javascript/Browser access to couchDB. I am going to access couchDB from a fairly low level within Ruby in these posts. OK, enough of the command shell let’s do some couchDB work using RUBY. Note that the order of the fields is set by couchDB not the order in the first loaded document. In couchDB Futon this document looks like: The format of the command is: curl -X PUT want to create a database named deadbase so on my system this command and response looks like:Ĭ:\Documents and Settings\dredfield\My Documents\Aptana Studio Workspace\couchDB01 Couchdb is RESTful so we use a PUT command for all actions which CREATE a resource, of which a database is one example. In the command shell you can create a couchdb Database using a POST command and CURL. This figure illustrates the setup within the Aptana IDE to do this: If you are using the Aptana IDE like me you need to create an “external command” to open a command shell within Aptana. If you must have a UNIX type shell you need to install CYWIN or some other UNIX emulator for Windows. Now open a ‘command prompt’ on your system. We assume here that couchDB has been installed successfully on your system. Use the version labeled DOS, Win32- MSVC or Win64 depending on your system. Either set your system path to include the CURL executable. Since we are running Windows first we need to install CURL on our system. These examples use CURL in a command shell. The examples in that chapter show us how to: create a database, to create and post a design document and to post a document to the database. Specifically they don’t work ‘out of the box’. If you are a windows user you may have run into some problems with the examples given in the chapter on “Design Documents”. If you are like me you have spent some time with the free ebook: CouchDB The Definitive Guide. Posting Documents to couchDB Using Ruby.Part 6 – Getting The Data Into And Out Of CouchDB Part 5 – Getting The Data Ready for CouchDB Part 0 – REST, Ruby On Rails, CouchDB and Me
0 Comments
Leave a Reply. |