Store ids containing table info
This commit is contained in:
parent
ff3bbf6217
commit
fc831db06b
|
@ -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,
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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()}`
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue