Code Monkey home page Code Monkey logo

Comments (26)

dscape avatar dscape commented on June 14, 2024

Personally I like it and think it makes a lot of sense. I just don't know if the name update is appropriate. I would agree it is but I'm afraid it will make people miss understand the function.

Can you make a pull request that includes necessary tests? I know tests suck right now but I didn't have enough time to port them to Mocha yet! :)

Then a blog post introducing this would be great. Version should be 1.2.x since it's an API change.

Anyone else would like to add opinions? @perezd @pgte @mikeal @PatrickHeneise ?

from nano.

dscape avatar dscape commented on June 14, 2024

Oh and btw, thank you. This is the kind of collaboration that makes everyone love open source :)

Welcome to the nano team! ;)

from nano.

PatrickHeneise avatar PatrickHeneise commented on June 14, 2024

At the moment I'm using the add-Handler to update documents. An update-Handler certainly makes sense! Great work, thanks!

from nano.

perezd avatar perezd commented on June 14, 2024

I think emphasizing design docs (ie: not relying on generic terminology such as update) is important. My 2 cents!

from nano.

dscape avatar dscape commented on June 14, 2024

@perezd how do you think the interface should look like?

from nano.

perezd avatar perezd commented on June 14, 2024

Oh wow, I totally didn't know about this feature, I thought this was a validate_doc_update design doc thing.

from nano.

dscape avatar dscape commented on June 14, 2024

:) Still what do you think the interface should be? Just update?

from nano.

dscape avatar dscape commented on June 14, 2024

Btw since we are all kind of here, I've added a samples directory to nano.

Feel free to populate with common cookbook style examples so people can get started faster.

from nano.

perezd avatar perezd commented on June 14, 2024

updateWithHandler?

from nano.

twilson63 avatar twilson63 commented on June 14, 2024

Cool,

I will create a pull request w/tests and name the public interface name "updateWithHandler" and the private function "update_doc_with_handler"? Sound Good?

from nano.

dscape avatar dscape commented on June 14, 2024

@twilson63 yes!

Imho you should make the name update though. I don't see enough reason not too, since no one complained too much or shouted at me too much.

I think simplicity should prevail.

Your call! :)

from nano.

perezd avatar perezd commented on June 14, 2024

prepared to be shouted at :)

there is no such thing as an "UPDATE" in couchDB. the PUT verb, is used for atomic saves, and all changes are atomically versioned, and unique. We have no notion of "updating a key" or things of this nature. So I think its useful to make sure that lexicon is carefully guarded.

from nano.

dscape avatar dscape commented on June 14, 2024

updateWithHandler it is ;)

from nano.

twilson63 avatar twilson63 commented on June 14, 2024

How does this post look, please suggest changes/modifications...

http://jackhq.tumblr.com/post/16035106690/nano-v1-2-x-document-update-handler-support-v1-2-x

from nano.

pfiled avatar pfiled commented on June 14, 2024

Be aware, it is still possible to get conflicts. A document update handler is like a really fast client, it does not change how couchdb works:

http://stackoverflow.com/questions/2983220/can-a-couchdb-document-update-handler-get-an-update-conflict

from nano.

twilson63 avatar twilson63 commented on June 14, 2024

Hey Daniel,

Thanks for the heads up, we will continue to test and benchmark, but the
document handlers have definitely made a huge difference, compared to view
-> put. When calling a view then updating a document, the view would
return the same document for several hundred milliseconds. With document
handlers, the view may not be instant but it is definitely updated by 100ms.

Do you have any other suggestions?

Thanks

Tom

On Wed, Jan 18, 2012 at 12:11 AM, Daniel Pfile <
[email protected]

wrote:

Be aware, it is still possible to get conflicts. A document update handler
is like a really fast client, it does not change how couchdb works:

http://stackoverflow.com/questions/2983220/can-a-couchdb-document-update-handler-get-an-update-conflict


Reply to this email directly or view it on GitHub:
#50 (comment)

Tom Wilson
Jack Russell Software Company LLC
1067 Cliffwood Drive
Mount Pleasant, SC 29464
Phone: 843-606-0637
Email: [email protected]
Web: http://www.jackhq.com
Calendar: http://www.jackhq.com/calendar

from nano.

dscape avatar dscape commented on June 14, 2024

@pfiled While that is useful information it doesn't relate much to nano.

If you guys are concerned I would suggest adding a sample to the samples/ directory, which includes conflict detection.

from nano.

mark-hahn avatar mark-hahn commented on June 14, 2024

I need to use body data with updateWithHandler. My data can be arbitrarily large so it cannot go into the url. I can fork it for now to get what I need but is there some reason it was not set up as body data in the first place? I can think of no reason to not always use the body.

from nano.

twilson63 avatar twilson63 commented on June 14, 2024

@mark-hahn just an oversight, when I implemented it, I was not sending body data, so I did not include that use case.

from nano.

mark-hahn avatar mark-hahn commented on June 14, 2024

It would be cool if params in relax had an option such as _httpBody. Then
if _httpBody exists it would always use that instead of opts.body. This
way one could always choose whether to use a query string or body right at
the nano call.

from nano.

dscape avatar dscape commented on June 14, 2024

please gist me some code to see what this would mean

nice new avatar @perezd

from nano.

mark-hahn avatar mark-hahn commented on June 14, 2024

My code is unfortunately proprietary. Are you looking for an explanation
of why someone would want to use body data instead of query data, or for
the how?

The why is simple. My framework supports updating a doc with an
arbitrarily large amount of data which couldn't fit in a url. I use a
general purpose update handler for every Create and Update operation (from
CRUD).

Off the top of my head the how would be ...

db.updateWithHandler 'design', 'update', id, { _httpBody: bodydata}, (err,
resp, hdrs) ->

I don't know nano very well, so I couldn't say whether this would be useful
for other operations that are url-only at the moment.

I've got everything working here by patching updateWithHandler to send an
opts.body to relax(). It was amazing at how quickly I replaced my old crap
with nano. It just worked. I especially like piping attachments.

from nano.

dscape avatar dscape commented on June 14, 2024

I meant the patch, have no interest in your application code :)

I want to understand how big of a change this is, if it means an api change, if it's relevant (the relax method is always there and can be used for uncommon operations, the updatehandler is already uncommon to start with)

from nano.

dscape avatar dscape commented on June 14, 2024

Thanks for the compliment, but most of the credit for that goes to @mikeal for request :)

from nano.

mark-hahn avatar mark-hahn commented on June 14, 2024

I think you (we, I) should just switch the updatehandler call to use the
body. This would be backwards compatible. This could be done for all
other public calls that have this problem, if any. If you want a pull
request let me know. Even the tests wouldn't change.

from nano.

dscape avatar dscape commented on June 14, 2024

Sounds good, those were my concerns.

Pull request is welcome!

from nano.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.