Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Beautified JSON written to file
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Jan 14, 2012
1 parent 6e2a75d commit ea363a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ Here is a list of [Contributors](http://github.com/pksunkara/nosqlite/contributo
- Authentication system
- Map-Reduce (views)
- Auto ID generation
- Beautify JSON written to file
__I accept pull requests and guarantee a reply back within a day__
Expand Down
8 changes: 4 additions & 4 deletions nosqlite.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ nosqlite.Connection::database = (name, mode) ->
put: (id, obj, cb) ->
@get id, (err, data) ->
data = @project JSON.parse(data), obj
fs.writeFile @file(id), JSON.stringify(data), cb
fs.writeFile @file(id), JSON.stringify(data, null, 2), cb

putSync: (id, obj) ->
data = @project JSON.parse(@getSync(id)), obj
fs.writeFileSync @file(id), JSON.stringify(data)
fs.writeFileSync @file(id), JSON.stringify(data, null, 2)

# Create doc
post: (obj, cb) ->
fs.writeFile @file(obj.id or obj._id), JSON.stringify(obj), cb
fs.writeFile @file(obj.id or obj._id), JSON.stringify(obj, null, 2), cb

postSync: (obj) ->
fs.writeFileSync @file(obj.id or obj._id), JSON.stringify(obj)
fs.writeFileSync @file(obj.id or obj._id), JSON.stringify(obj, null, 2)

# Find a doc
find: (cond, cb) ->
Expand Down

0 comments on commit ea363a8

Please sign in to comment.