From 7610065db14f2b3f8b1df7b3a485f1e9b7a3a701 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Tue, 22 Nov 2022 16:28:51 +0000 Subject: [PATCH] Fix view creation --- packages/backend-core/src/db/views.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend-core/src/db/views.ts b/packages/backend-core/src/db/views.ts index 5c63ce4689..c563d55be3 100644 --- a/packages/backend-core/src/db/views.ts +++ b/packages/backend-core/src/db/views.ts @@ -145,7 +145,9 @@ export const queryView = async ( return docs.length <= 1 ? (docs[0] as T) : (docs as T[]) } } catch (err: any) { - if (err != null && err.name === "not_found") { + const pouchNotFound = err && err.name === "not_found" + const couchNotFound = err && err.status === 404 + if (pouchNotFound || couchNotFound) { await removeDeprecated(db, viewName) await createFunc() return queryView(viewName, params, db, createFunc, opts)