Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm planning to use Node for my next project, because it seems to be a good fit for the problem I'm solving.

One thing I need to figure out is optimistic and pessimistic locking. http://guides.rubyonrails.org/active_record_querying.html#locking-records-for-update

Say, the user has a balance of 1. Two Node instances make requests concurrently to withdraw 1. The two requests could pass the check of sufficient balance at the same time, thus making two successful withdrawals resulting in a balance of -1.

Rails provides a wrapper around Postgres transactional and locking features. Does some kind of similar wrapper exist for Node?

How do you solve this in Node/Postgresql?

I know this is a database feature, but I wonder if Node or some library provides a abstraction away from writing raw SQL queries?

share|improve this question
    
I just came across the following link and thought of your question, though it might not have anything whatsoever to do with what you are after. github.com/commandprompt/postgres-js –  bma Nov 21 '13 at 16:30
    
It's definitely not a feature of Node as it has no functionality related to databases. –  WiredPrairie Nov 21 '13 at 18:10
add comment

closed as off-topic by WiredPrairie, Andrew Barber Nov 21 '13 at 19:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – WiredPrairie, Andrew Barber
If this question can be reworded to fit the rules in the help center, please edit the question.