MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / uniqueFieldName

Function uniqueFieldName

packages/app-core/src/lib/database-cells.ts:98–104  ·  view source on GitHub ↗
(doc: DatabaseDoc, base: string)

Source from the content-addressed store, hash-verified

96// --- schema / view mutations (→ updateDatabaseSchema) -------------------
97
98function uniqueFieldName(doc: DatabaseDoc, base: string): string {
99 const taken = new Set(doc.fields.map((f) => f.name))
100 if (!taken.has(base)) return base
101 let n = 2
102 while (taken.has(`${base} ${n}`)) n++
103 return `${base} ${n}`
104}
105
106export function addField(doc: DatabaseDoc, type: FieldType = 'text', name = 'New field'): DatabaseDoc {
107 const field: DbField = {

Callers 2

addFieldFunction · 0.85
renameFieldFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected