Skip to content

Commit

Permalink
forgot some files
Browse files Browse the repository at this point in the history
  • Loading branch information
janmonschke committed Aug 18, 2011
1 parent 27e65a1 commit 51fc238
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 12 additions & 3 deletions backbone-couchdb.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ Backbone.couch_connector = con =
read_collection : (coll, opts) ->
_view = @config.view_name
keys = [@helpers.extract_collection_name coll]
console.log "keys", keys, @helpers.extract_collection_name(coll)
if coll.db?
coll.listen_to_changes() if coll.db.changes or @config.global_changes
if coll.db.view?
_view = coll.db.view
keys = coll.db.keys ? []

@helpers.make_db().view "#{@config.ddoc_name}/#{_view}",
if coll.db.keys?
keys = coll.db.keys

_opts =
keys : keys
success : (data) =>
_temp = []
Expand All @@ -68,6 +70,13 @@ Backbone.couch_connector = con =
opts.success _temp
error : ->
opts.error()

# delete keys if a custom view is requested but no custom keys
if coll.db? and coll.db.view? and not coll.db.keys?
delete _opts.keys

@helpers.make_db().view "#{@config.ddoc_name}/#{_view}", _opts


# Reads a model from the couchdb by it's ID
read_model : (model, opts) ->
Expand Down
15 changes: 11 additions & 4 deletions backbone-couchdb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51fc238

Please sign in to comment.