Permalink
Browse files

more readme stuffw

  • Loading branch information...
1 parent 23ba9db commit 7e440deeba3745380b0c26fb5c190044c9e48939 @rockymeza committed May 12, 2011
Showing with 11 additions and 12 deletions.
  1. +11 −12 README.md
View
@@ -7,12 +7,10 @@
couchy is a CouchDB wrapper for node and CoffeeScript. couchy tries to have a developer-friendly, but minimal API. I plan to make possible everything you can do with CouchDB, and add some helpers that I find useful.
-Connect to Database
--------------------
+## Connect to Database
db = require('couchy')('mydb')
-Setup and Destroy
------------------
+## Setup and Destroy
`db.create([callback])`
```coffee-script
@@ -27,8 +25,7 @@ db.destroy (err) ->
console.log 'destroyed mydb'
```
-Queries
--------
+## Queries
The query method has a flexible invocation. All arguments after method are optional, but any of them can be included, so long as they remain in order. Instead of having to do something like this, `db.query 'head', '', {}, ->`, you can simplify your call to `db.query 'head', ->`.
`db.query(method:string, [path:string], [data:object], [callback(error, response, body)])`
@@ -41,8 +38,7 @@ db.query 'post', 'someid', {foo: bar}, (err, res, body) ->
console.log body
```
-Views
------
+## Views
`db.view(path:string, callback)`
```coffee-script
@@ -59,8 +55,7 @@ db.view 'app/thingsByName', {key: 'Foo'}, (err, res) ->
console.log thing
```
-Seeding
--------
+## Seeding
This is mainly for creating test data. It takes a callback would should return
`db.seed(doc_callback, callback || noop)`
@@ -78,7 +73,11 @@ This works for creating a document in the database. What if I need a bunch?
db.seed 10, ->
type: 'thing', name: 'Foo', string: @string(15), number: @number(144, 2), thing: @pick(['this', 'that'])
```
+### Seeding Helpers
-Module Exports
---------------
+- number(max = 100, precision = 0) -- creates a random number and rounds to a precision
+- string(length = 10) -- creates a random string using charcodes 65-122 (A-z)
+- pick(choices) -- picks randomly from an array
+
+## Module Exports
The couchy module exports a function that can be used to create a Database connection. It also exports the Database class, which can be used for type checking.

0 comments on commit 7e440de

Please sign in to comment.