1. Ola Sandström
  2. ubud-db

Wiki

Clone wiki

ubud-db / Home

Welcome to Ubud

Welcome to Ubud! Ubud is a document store on AppEngine with a REST-JSON API.

Try Ubud

You can try Ubud right now, using your favorite browser or a simple REST client.

GET http://ubud-db.appspot.com/ubud/ubud-test/Wiki/Hello

to load your first Ubud document. Username is 'admin' and password is 'topsecret'.

Contents

CRUD operations

The REST url to Ubud is built using this formatting:

http://ubud-db.appspot.com/ubud/{namespace}/{kind}[/{id}]

CRUD is mapped to the following HTTP methods:

  • POST without {id} to Create a document, the generated id is returned in the response Contents.
  • GET with {id} to Read a document
  • POST with {id} or _id to Update a document
  • DELETE with {id} to Delete a document

Create Example

POST http://ubud-db.appspot.com/ubud/ubud-test/Echo
Content-Type: application/json

{
   "message":"Hello Ubud world!",
   "alt":42
}

can be posted using the simple wget command:

echo -e {\"message\":\"Hello Ubud world\!\",\"alt\":42} > echo1.json
wget --quiet --user=admin --password=topsecret \\
     --post-file=echo1.json --header=Content-Type:application/json \\
     --output-document=- http://ubud-db.appspot.com/ubud/ubud-test/Echo

will give you the generated id in front of the prompt on next line, e.g.

5{color:green}os@ola-T400-mint{color} {color:cyan}/tmp ${color}

which indicates an id with value '5'.

Query Example

GET http://ubud-db.appspot.com/ubud/ubud-test/Echo?q={"alt":42}

will give you

[{"_id":5,"alt":42,"message":"Hello Ubud world!"}]

Adding the query param single=1 returns the unique document or null:

GET http://ubud-db.appspot.com/ubud/ubud-test/Echo?q={"alt":42}&single=1

will give you

{"_id":5,"alt":42,"message":"Hello Ubud world!"}

Updated