Closed ranoble closed 3 years ago
ah foo, looks like we don't have a test for designDocs
Howdy! It looks like this issue has been fixed. You can demonstrate it with this code:
const assert = require('assert').strict
const PouchDB = require('pouchdb')
PouchDB.plugin(require('crypto-pouch'))
const NAME = '.test'
const PASSWORD = 'hello world'
const DOC = { _id: 'a', hello: 'world' }
const DDOC = {
_id: '_design/test',
views: {
test: {
map: function(doc) {
emit(doc.hello)
}.toString()
}
}
}
const db = new PouchDB(NAME)
db.crypto(PASSWORD).then(async () => {
await db.put(DOC)
await db.put(DDOC)
const result = await db.query('test')
assert.equal(result.total_rows, 1)
assert.equal(result.offset, 0)
assert.equal(result.rows.length, 1)
assert.equal(result.rows[0].key, 'world')
assert.equal(result.rows[0].id, 'a')
assert.equal(result.rows[0].value, null)
console.log('ok')
}).catch((err) => {
console.error(err)
}).then(async () => {
await db.destroy()
})
Running this should print this result:
ok
Since it's been a few years, I'm going to close this issue for now. Let me know if you're still having trouble!
The plugin seems awesome, so lets start with that.
I put together the snippet below to show the issue (removed error handling for brevity).
I am using the browserify version, as this is running in browser.
Steps, create a DB, crypto it, add a document, add a design document view, and try and query it. {status: 404, name: "not_found", message: "missing", error: true, reason: "missing"}, and seems to indicate that the view can't be found.
Any ideas would be most welcome.