couchbaselabs / beersample-node

Sample web application using node.js, couchnode and libcouchbase to access couchbase server.
8 stars 9 forks source link

Basic part of sample doesn't work. With clean setup, cannot edit a beer. Solution included. #3

Open neatcode opened 10 years ago

neatcode commented 10 years ago

If you click on [Edit] for any beer, and edit any field and then press [Save Changes], the following error is printed to the browser:

ReferenceError: rc is not defined
    at done_edit_beer (c:\git\5\beersample-node\beer_app.js:163:13)
    at callbacks (c:\git\5\beersample-node\node_modules\express\lib\router\index.js:164:37)
    at param (c:\git\5\beersample-node\node_modules\express\lib\router\index.js:138:11)
    at param (c:\git\5\beersample-node\node_modules\express\lib\router\index.js:135:11)
    at pass (c:\git\5\beersample-node\node_modules\express\lib\router\index.js:145:5)
    at Router._dispatch (c:\git\5\beersample-node\node_modules\express\lib\router\index.js:173:5)
    at Object.router (c:\git\5\beersample-node\node_modules\express\lib\router\index.js:33:10)
    at next (c:\git\5\beersample-node\node_modules\express\node_modules\connect\lib\proto.js:190:15)
    at Object.staticMiddleware [as handle] (c:\git\5\beersample-node\node_modules\express\node_modules\connect\lib\middleware\static.js:55:61)
    at next (c:\git\5\beersample-node\node_modules\express\node_modules\connect\lib\proto.js:190:15)

Solution

It seems that rc. was erroneously added to the front of rc.doc.brewery_id on line 163 of beer_app.js. Remove the text rc., save the file, and restart the server and the edit feature now works.

  db.get( rc.doc.brewery_id, function(err, result) {

becomes

  db.get( doc.brewery_id, function(err, result) {

Editing should now work.

Note: I'm really surprised this hasn't been noticed for nearly a year now. Is nobody learning to use Couchbase on Node.js?

Note #2: I really wish there were more sample applications for Node.js, more full-fledged examples that show best practices of using Node.js and of using Couchbase. Samples with production-ready error handling, and samples that are perhaps designed to demonstrate the scalability of couchbase as part of the application (like perhaps some data-processing on statistics or something involving alot of data crunching, maybe GeoSpatial). Perhaps someone could suggest some solid open source projects which do this, for me to look over?

jhoobergs commented 9 years ago

after changing that you also have to change line 164 to result ===undefined I got an error with result.value that it is not possible to read attribute of null