1
0
Fork 0
mirror of synced 2024-07-14 18:55:45 +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({
...newView,
id: expect.any(String),
id: expect.stringMatching(new RegExp(`^vi_${config.table?._id!}_`)),
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.
*/
export function generateViewID(tableId: string) {
return `${viewIDPrefix(tableId)}${newid()}`
}
export function viewIDPrefix(tableId: string) {
return `${DocumentType.VIEW}${SEPARATOR}${tableId}${SEPARATOR}`
return `${DocumentType.VIEW}${SEPARATOR}${tableId}${SEPARATOR}${newid()}`
}

View file

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