     deleteById : (id) ->
       deleted.push id
 
-    getById : (id) -> clone @bucket[id]
+    getById : (id, includeDirty = false) ->
+      if includeDirty
+        included = _.extend {}, @bucket, @dirty
+        clone included[id]
+      else
+        clone @bucket[id]
 
     getByIds : (list) ->
       _.map list, (id) -> clone @bucket[id]



    store : (cb) ->
      do (@fileName, @bucket, @dirty, cb) ->

        _.each @deleted, (id) -> @dirty[id] = {deleted:true, id:id}


      itm = clone itm if itm?
      itm

    where : (properties, includeDirty = false) ->
      if includeDirty
        _.map _.where(_.extend({}, @bucket, @dirty), properties), (itm) ->clone(itm)
      else
        _.map _.where(@bucket, properties), (itm) -> clone(itm)

    set : (object) ->
      @dirty[object.id] = clone(object)
