lontongcorp / feathers-couchdb

Feathers couchdb adapter service using node-cradle
MIT License
15 stars 6 forks source link

Problem with _design/feathers view #3

Open jay-jlm opened 7 years ago

jay-jlm commented 7 years ago

Sometimes it creates some temporary view and starts giving out this error like it cannot delete it, this both in local couchdb, not just on Bluemix, not even removing the view and restarting the server can make this go away

/Users/joao/node_projects/proto-server/node_modules/cradle/lib/cradle.js:244 callback(null, self.options.raw ? body : new cradle.Response(body, res)); ^ TypeError: Cannot read property 'rev' of undefined at /Users/joao/node_projects/proto-server/node_modules/feathers-couchdb/lib/index.js:230:70 at Request._onResponse [as _callback] (/Users/joao/node_projects/proto-server/node_modules/cradle/lib/cradle.js:244:9) at Request.self.callback (/Users/joao/node_projects/proto-server/node_modules/request/request.js:188:22) at emitTwo (events.js:106:13) at Request.emit (events.js:194:7) at Request.<anonymous> (/Users/joao/node_projects/proto-server/node_modules/request/request.js:1171:10) at emitOne (events.js:96:13) at Request.emit (events.js:191:7) at IncomingMessage.<anonymous> (/Users/joao/node_projects/proto-server/node_modules/request/request.js:1091:12) at Object.onceWrapper (events.js:293:19)

jay-jlm commented 7 years ago

When logging the state after this line:

function (err, obj) { db.view('feathers/temp', opts, function (err, res) {

the first err is null but value of obj is undefined... is this expected behavior??

liquidcowgithub commented 5 years ago

In case anyone else comes across this issue; The trick is to create an appropriate design view (as per this package's readme/docs).

In context of a feathers service, you can get started by creating a design doc:

service.create({ "_id": "_design/things", "views": { "all": { "map": "function (doc/*``*/) {if (doc && doc.myFilterProperty == true) {emit(null, doc);}}" } } })

and then any time you query via the feathers service:

service('things').find({ query: { q: "things/all", ... } });

More importantly, it doesn't look like this package is maintained? So maybe stay away, or use cradle directly?