(db, fun, opts)
| 9041 | } |
| 9042 | |
| 9043 | async function queryPromised(db, fun, opts) { |
| 9044 | /* istanbul ignore next */ |
| 9045 | if (typeof db._query === 'function') { |
| 9046 | return customQuery(db, fun, opts); |
| 9047 | } |
| 9048 | if (isRemote(db)) { |
| 9049 | return httpQuery(db, fun, opts); |
| 9050 | } |
| 9051 | |
| 9052 | const updateViewOpts = { |
| 9053 | changes_batch_size: db.__opts.view_update_changes_batch_size || CHANGES_BATCH_SIZE$1 |
| 9054 | }; |
| 9055 | |
| 9056 | if (typeof fun !== 'string') { |
| 9057 | // temp_view |
| 9058 | checkQueryParseError(opts, fun); |
| 9059 | |
| 9060 | tempViewQueue.add(async function () { |
| 9061 | const view = await createView( |
| 9062 | /* sourceDB */ db, |
| 9063 | /* viewName */ 'temp_view/temp_view', |
| 9064 | /* mapFun */ fun.map, |
| 9065 | /* reduceFun */ fun.reduce, |
| 9066 | /* temporary */ true, |
| 9067 | /* localDocName */ localDocName); |
| 9068 | |
| 9069 | return fin(updateView(view, updateViewOpts).then( |
| 9070 | function () { return queryView(view, opts); }), |
| 9071 | function () { return view.db.destroy(); } |
| 9072 | ); |
| 9073 | }); |
| 9074 | return tempViewQueue.finish(); |
| 9075 | } else { |
| 9076 | // persistent view |
| 9077 | const fullViewName = fun; |
| 9078 | const parts = parseViewName(fullViewName); |
| 9079 | const designDocName = parts[0]; |
| 9080 | const viewName = parts[1]; |
| 9081 | |
| 9082 | const doc = await db.get('_design/' + designDocName); |
| 9083 | fun = doc.views && doc.views[viewName]; |
| 9084 | |
| 9085 | if (!fun) { |
| 9086 | // basic validator; it's assumed that every subclass would want this |
| 9087 | throw new NotFoundError(`ddoc ${doc._id} has no view named ${viewName}`); |
| 9088 | } |
| 9089 | |
| 9090 | ddocValidator(doc, viewName); |
| 9091 | checkQueryParseError(opts, fun); |
| 9092 | |
| 9093 | const view = await createView( |
| 9094 | /* sourceDB */ db, |
| 9095 | /* viewName */ fullViewName, |
| 9096 | /* mapFun */ fun.map, |
| 9097 | /* reduceFun */ fun.reduce, |
| 9098 | /* temporary */ false, |
| 9099 | /* localDocName */ localDocName); |
| 9100 |
no test coverage detected
searching dependent graphs…