1
0
Fork 0
mirror of synced 2024-08-15 18:11:40 +12:00

Store ids containing table info

This commit is contained in:
Adria Navarro 2023-07-19 17:52:00 +02:00
parent ff3bbf6217
commit fc831db06b
3 changed files with 4 additions and 8 deletions

View file

@ -60,7 +60,7 @@ describe("/v2/views", () => {
expect(res).toEqual({ expect(res).toEqual({
...newView, ...newView,
id: expect.any(String), id: expect.stringMatching(new RegExp(`^vi_${config.table?._id!}_`)),
version: 2, version: 2,
}) })
}) })

View file

@ -277,9 +277,5 @@ export function getMultiIDParams(ids: string[]) {
* @returns {string} The new view ID which the view doc can be stored under. * @returns {string} The new view ID which the view doc can be stored under.
*/ */
export function generateViewID(tableId: string) { export function generateViewID(tableId: string) {
return `${viewIDPrefix(tableId)}${newid()}` return `${DocumentType.VIEW}${SEPARATOR}${tableId}${SEPARATOR}${newid()}`
}
export function viewIDPrefix(tableId: string) {
return `${DocumentType.VIEW}${SEPARATOR}${tableId}${SEPARATOR}`
} }

View file

@ -2,7 +2,7 @@ import { HTTPError, context } from "@budibase/backend-core"
import { View, ViewV2 } from "@budibase/types" import { View, ViewV2 } from "@budibase/types"
import sdk from "../../../sdk" import sdk from "../../../sdk"
import { utils as coreUtils } from "@budibase/backend-core" import * as utils from "../../../db/utils"
export async function get( export async function get(
tableId: string, tableId: string,
@ -21,7 +21,7 @@ export async function create(
): Promise<ViewV2> { ): Promise<ViewV2> {
const view: ViewV2 = { const view: ViewV2 = {
...viewRequest, ...viewRequest,
id: coreUtils.newid(), id: utils.generateViewID(tableId),
version: 2, version: 2,
} }