(db, fun, opts)
| 9079 | } |
| 9080 | |
| 9081 | async function queryPromised(db, fun, opts) { |
| 9082 | /* istanbul ignore next */ |
| 9083 | if (typeof db._query === 'function') { |
| 9084 | return customQuery(db, fun, opts); |
| 9085 | } |
| 9086 | if (isRemote(db)) { |
| 9087 | return httpQuery(db, fun, opts); |
| 9088 | } |
| 9089 | |
| 9090 | const updateViewOpts = { |
| 9091 | changes_batch_size: db.__opts.view_update_changes_batch_size || CHANGES_BATCH_SIZE$1 |
| 9092 | }; |
| 9093 | |
| 9094 | if (typeof fun !== 'string') { |
| 9095 | // temp_view |
| 9096 | checkQueryParseError(opts, fun); |
| 9097 | |
| 9098 | tempViewQueue.add(async function () { |
| 9099 | const view = await createView( |
| 9100 | /* sourceDB */ db, |
| 9101 | /* viewName */ 'temp_view/temp_view', |
| 9102 | /* mapFun */ fun.map, |
| 9103 | /* reduceFun */ fun.reduce, |
| 9104 | /* temporary */ true, |
| 9105 | /* localDocName */ localDocName); |
| 9106 | |
| 9107 | return fin(updateView(view, updateViewOpts).then( |
| 9108 | function () { return queryView(view, opts); }), |
| 9109 | function () { return view.db.destroy(); } |
| 9110 | ); |
| 9111 | }); |
| 9112 | return tempViewQueue.finish(); |
| 9113 | } else { |
| 9114 | // persistent view |
| 9115 | const fullViewName = fun; |
| 9116 | const parts = parseViewName(fullViewName); |
| 9117 | const designDocName = parts[0]; |
| 9118 | const viewName = parts[1]; |
| 9119 | |
| 9120 | const doc = await db.get('_design/' + designDocName); |
| 9121 | fun = doc.views && doc.views[viewName]; |
| 9122 | |
| 9123 | if (!fun) { |
| 9124 | // basic validator; it's assumed that every subclass would want this |
| 9125 | throw new NotFoundError$1(`ddoc ${doc._id} has no view named ${viewName}`); |
| 9126 | } |
| 9127 | |
| 9128 | ddocValidator(doc, viewName); |
| 9129 | checkQueryParseError(opts, fun); |
| 9130 | |
| 9131 | const view = await createView( |
| 9132 | /* sourceDB */ db, |
| 9133 | /* viewName */ fullViewName, |
| 9134 | /* mapFun */ fun.map, |
| 9135 | /* reduceFun */ fun.reduce, |
| 9136 | /* temporary */ false, |
| 9137 | /* localDocName */ localDocName); |
| 9138 |
no test coverage detected
searching dependent graphs…