Showing posts with label couchdb. Show all posts
Showing posts with label couchdb. Show all posts

Saturday, January 25, 2014

store json into couchdb with curl

file q1.json:
{
    "type": "quote",
    "author": "Thomas Hardy",
    "text": "And as the smart ship grew
In stature, grace, and hue
In shadowy silent distance grew the Iceberg too.", "work": { "title": "The Convergence Of The Twain", "link": "http://www.poetryfoundation.org/poem/176678", "year": 1915 } }
curl -u user:passwd -X POST http://localhost:5984/example -H 'Content-Type: application/json' -d @q1.json

setup node.js-based couchapp on FreeBSD

as root:

pkg install couchdb
couchdb -b

pkg install node
pkg install npm

# this brings problems
#npm install couchapp -g


as normal user:

mkdir myapp
cd myapp/

# workaround: install locally
npm install couchapp
./node_modules/.bin/couchapp boiler
# it complains that it cannot be created, but app.js and attachments are there
./node_modules/.bin/couchapp push app.js http://localhost:5984/myapp
$ tree myapp -L 4
myapp
|-- app.js
|-- attachments
|   |-- index.html
|   |-- jquery-1.4.4.min.js
|   |-- layout.css
|   |-- sammy
|   |   |-- plugins
|   |   |   |-- sammy.cache.js
|   |   |   |-- sammy.data_location_proxy.js
|   |   |   |-- sammy.ejs.js
|   |   |   |-- sammy.form.js
|   |   |   |-- sammy.haml.js
|   |   |   |-- sammy.json.js
|   |   |   |-- sammy.meld.js
|   |   |   |-- sammy.mustache.js
|   |   |   |-- sammy.nested_params.js
|   |   |   |-- sammy.path_location_proxy.js
|   |   |   |-- sammy.pure.js
|   |   |   |-- sammy.storage.js
|   |   |   |-- sammy.template.js
|   |   |   `-- sammy.title.js
|   |   `-- sammy.js
|   `-- site.js

setup python-based couchapp on FreeBSD


as root:

pkg install couchdb
couchdb -b

pkg install py27-virtualenv 
pkg install py27-pip


as normal user:

virtualenv couchapps
cd couchapps
. bin/activate
pip install couchapp

mkdir apps
cd apps/

couchapp generate app1
cd app1
git init
couchapp push . http://localhost:5984/example