Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow collections to specify their own design document #38

Merged
merged 2 commits into from
Apr 2, 2012

Conversation

radicand
Copy link
Contributor

@radicand radicand commented Apr 2, 2012

Much like we can specify a view other than "byCollection", this PRQ allows a collection to specify its own design document if it differs from the default.

@janmonschke
Copy link
Owner

I just accepted another PRQ in the main repo, can you fetch the changes and merge them, so I can merge this one to the main repo as well?

@radicand
Copy link
Contributor Author

radicand commented Apr 2, 2012

Done-- It should merge now, let me know if you need anything else.

@janmonschke
Copy link
Owner

Awesome thx :)
If you like you can write a little text about that feature so I can put in in the documentation under 'recipes' at http://janmonschke.com/projects/backbone-couchdb.html

janmonschke added a commit that referenced this pull request Apr 2, 2012
Allow collections to specify their own design document
@janmonschke janmonschke merged commit bd0a2ea into janmonschke:master Apr 2, 2012
@radicand
Copy link
Contributor Author

radicand commented Apr 2, 2012

Heh, it's pretty straightforward:

If you need your collection to be sourced from a different design document, you can use the db.ddoc Collection option to specify a new design document:

  Backbone.couch_connector.config.ddoc_name = "my_main_design_doc"

  var mainCollection = Backbone.Collection.extend({
    db : {
      view : "myCollection"
    }
    ....
  });

  var otherCollection = Backbone.Collection.extend({
    db : {
      view : "myCollection",
      ddoc : "my_other_design_doc"
    }
    ....
  });

This results in mainCollection sourcing from _design/my_main_design_doc/_view/myCollection and otherCollection sourcing from _design/my_other_design_doc/_view/myCollection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants