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