diff --git a/packages/core/src/templateApi/createNodes.js b/packages/core/src/templateApi/createNodes.js
index 113c6ff0ea..804445b4e9 100644
--- a/packages/core/src/templateApi/createNodes.js
+++ b/packages/core/src/templateApi/createNodes.js
@@ -160,16 +160,17 @@ export const getNewRootLevel = () =>
})
const _getNewRecordTemplate = (parent, name, createDefaultIndex, isSingle) => {
+ const nodeId = getNodeId(parent)
const node = constructNode(parent, {
name,
type: "record",
fields: [],
children: [],
validationRules: [],
- nodeId: getNodeId(parent),
+ nodeId: nodeId,
indexes: [],
estimatedRecordCount: isRecord(parent) ? 500 : 1000000,
- collectionName: "",
+ collectionName: (nodeId || "").toString(),
isSingle,
})
diff --git a/packages/core/test/templateApi.constructHeirarchy.spec.js b/packages/core/test/templateApi.constructHeirarchy.spec.js
index 44991ed403..1435f5dbec 100644
--- a/packages/core/test/templateApi.constructHeirarchy.spec.js
+++ b/packages/core/test/templateApi.constructHeirarchy.spec.js
@@ -25,7 +25,7 @@ describe("hierarchy node creation", () => {
expect(record.validationRules).toEqual([])
expect(record.indexes).toEqual([])
expect(record.parent()).toBe(root)
- expect(record.collectionName).toBe("")
+ expect(record.collectionName).toBe(record.nodeId.toString())
expect(record.estimatedRecordCount).toBe(1000000)
expect(record.isSingle).toBe(false)