couchbaselabs / couchbaselabs/beersample-node

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

Open
#3 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8
Forks
8
PR merge metrics
No merged PRs in 30d

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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.