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

Changed Backbone.couch_connector.update to use $.couch.db.updateDoc #43

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

gijohnson-usgs
Copy link

Referencing Issue #42, this change allows the use of CouchDB's update handlers.

Usage:

con.update(model, {
  updateFun : "update_handler",
  attr1 : attr1,
  attr2 : attr2,
  ...
  success : function(doc) {
    ...
  },
  error : function(doc) {
    ...
  }
})

I'm also interested in having Backbone.couch_connector.create call this function if the user provides an "updateFun" option.

@janmonschke
Copy link
Owner

Looks good to me, but can you merge in latest master first and then run the tests? (https://github.com/janmonschke/backbone-couchdb/blob/master/test/readme.md)

@gijohnson-usgs
Copy link
Author

Tests are passing, but I'd like to add some more.

- Add tests for using the update function w/ an update handler.

- Update test/testrunner/src/jquery.couch.js to
  https://github.com/daleharvey/jquery.couch.js

- Move updateFun from options to the model.

- Allow user to update all model attributes or just ones passed to
  model.save
@gijohnson-usgs
Copy link
Author

I've add more tests and moved the updateFun from opts to the model. I think this is more intuitive, but if you have other suggestions I'd love to hear them.

@gijohnson-usgs
Copy link
Author

Another option is to add updateDoc if it doesn't exist.

@janmonschke
Copy link
Owner

That's another option, we could do that.
But then we'd also have to maintain that function.

Let's try with including the function.

@gijohnson-usgs
Copy link
Author

Would you like it added to $.couch.db or perhaps in Backbone.couch_connector.helpers?

@gijohnson-usgs
Copy link
Author

I decided not to include it b/c $.couch is using a few nested closures and updateDoc relies on one 'private' method called encodeOptions.

@gijohnson-usgs
Copy link
Author

Changed my mind. Now there is a check in update that binds update_doc and it's dependency encode_options to the db object if $.couch doesn't contain it. All tests are passing.

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