Fixing an issue where the table that a view was attached to was not being retrieved correctly, inhibiting the ability to enrich with relationships.

This commit is contained in:
mike12345567 2021-02-24 16:55:06 +00:00
parent ef069f9a1c
commit d16015587f
1 changed files with 6 additions and 1 deletions

View File

@ -202,6 +202,11 @@ exports.fetchView = async function(ctx) {
const db = new CouchDB(appId) const db = new CouchDB(appId)
const { calculation, group, field } = ctx.query const { calculation, group, field } = ctx.query
const designDoc = await db.get("_design/database")
const viewInfo = designDoc.views[viewName]
if (!viewInfo) {
ctx.throw(400, "View does not exist.")
}
const response = await db.query(`database/${viewName}`, { const response = await db.query(`database/${viewName}`, {
include_docs: !calculation, include_docs: !calculation,
group, group,
@ -211,7 +216,7 @@ exports.fetchView = async function(ctx) {
response.rows = response.rows.map(row => row.doc) response.rows = response.rows.map(row => row.doc)
let table let table
try { try {
table = await db.get(ctx.params.tableId) table = await db.get(viewInfo.meta.tableId)
} catch (err) { } catch (err) {
table = { table = {
schema: {}, schema: {},