         blog: 'drey.com'
         source: 'twitter'
       item = db.save 'users', user
-      items = db.find 'users', { name: 'David' }
+      items = db.find 'users', name: 'David'
       expect(items.length).to.equal 2
 
     it "should return an empty object if no match on find one", ->
-      item = db.findOne 'users', { name: 'Paul' }
+      item = db.findOne 'users', name: 'Paul'
       expect(typeof item).to.equal 'object'
       expect(Object.keys(item).length).to.equal 0
 
     it "should return an empty array if no match on find all", ->
-      items = db.find 'users', { name: 'Paul' }
+      items = db.find 'users', name: 'Paul'
       expect(items.push).to.be.a 'function'
       expect(items.length).to.equal 0
 
     it "should return a pure object when find one", ->
-      item = db.findOne 'users', { username: 'dreyacosta' }
+      item = db.findOne 'users', username: 'dreyacosta'
       expect(item.name).to.equal 'David'
       item.name = 'Mike'
-      item = db.findOne 'users', { username: 'dreyacosta' }
+      item = db.findOne 'users', username: 'dreyacosta'
       expect(item.name).to.equal 'David'
 
     it "should return a pure array when find all", ->

DB = require '../index'

describe "JSONdb module", ->
  describe "Persistence and memory tests", ->
    it "should set new database path", ->
      db = new DB './database.json'
      expect(db.databasePath).to.equal './database.json'

        blog: 'pirish.com'
        source: 'twitter'
      item = db.save 'users', user
      items = db.find 'users', source: 'twitter'
      expect(items.length).to.equal 3
      items[0].source = 'facebook'
      items = db.find 'users', source: 'twitter'
      expect(items.length).to.equal 3

    it "should return a pure object when update", ->
      item = db.findOne 'users', username: 'dreyacosta'
      item = db.update 'users', item.id, name: 'David Rey'
      expect(item.name).to.equal 'David Rey'
      item.name = 'Mike'
      item = db.findOne 'users', username: 'dreyacosta'
      expect(item.name).to.equal 'David Rey'

    it "should update item", ->
      data =
        country: 'Spain'
      item = db.findOne 'users', username: 'drey'
      item = db.update 'users', item.id, data
      expect(item.country).to.equal 'Spain'

    it "should remove item from a collection", ->
      item = db.findOne 'users', username: 'drey'
      expect(item.username).to.equal 'drey'
      result = db.remove 'users', item.id
      expect(result).to.equal true
      item = db.findOne 'users', id: item.id
      expect(typeof item).to.equal 'object'
      expect(Object.keys(item).length).to.equal 0

