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

Open Beginner friendly
#3 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript, node.js
Domain
backend, web-dev

Research direction

Inspect beer_app.js at done_edit_beer around line 163, then reproduce the edit-and-save flow in a clean setup. Confirm that saving an edited beer completes without the reported ReferenceError and that the edit is persisted after restarting the server.

Written by the indexing model from the issue text.

Description

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?

Dominant language
JavaScript
Stars
8
Forks
8
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from couchbaselabs/beersample-node

All issues in couchbaselabs/beersample-node

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.