couchbaselabs / couchbaselabs/beersample-node

Error running --setup

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

Description

If there is no "design" in the "beer-samples" bucket called "beer", running `node beer.js --setup` fails with the following error:

```
$ node beer.js --setup

c:\git\5\beersample-node\beer_designs.js:37
if(! ('by_name' in ddoc['views']) ) {
^
TypeError: Cannot read property 'views' of null
at c:\git\5\beersample-node\beer_designs.js:37:36
at c:\git\5\beersample-node\node_modules\couchbase\lib\bucketmgr.js:131:14
at IncomingMessage. (c:\git\5\beersample-node\node_modules\couchb
ase\lib\bucketmgr.js:11:7)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)
```

What's funny is that this condition (having no document found) appears to be handled when the code that follows creates the "brewery" view -- it checks for `err` and creates a breweries design object. But this check isn't done when creating the "beers" view.

The code should be fixed. However, my workaround was to go to the database administration console, and add a fake view called `fake` under a design named specifically `beer`. This results in
`node beer.js --setup` successfully running, and the application working when started.

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.