(
name: string,
edef: EntityDef<
AttrsDefs,
Record<string, LinkAttrDef<CardinalityKind, string>>,
any
>,
)
| 271 | } |
| 272 | |
| 273 | function entityDefToCodeStr( |
| 274 | name: string, |
| 275 | edef: EntityDef< |
| 276 | AttrsDefs, |
| 277 | Record<string, LinkAttrDef<CardinalityKind, string>>, |
| 278 | any |
| 279 | >, |
| 280 | ) { |
| 281 | const attrBlock = joinWithTrailingSep( |
| 282 | sortedEntries(edef.attrs).map(attrDefToCodeString), |
| 283 | ',\n', |
| 284 | ',', |
| 285 | ); |
| 286 | |
| 287 | // a block of code for each entity |
| 288 | return `${formatKey(name)}: i.entity({${attrBlock.length ? '\n' : ''}${indentLines(attrBlock, 2)}${attrBlock.length ? '\n' : ''}})`; |
| 289 | } |
| 290 | |
| 291 | export function identEtype(ident: InstantDBIdent) { |
| 292 | return ident[1]; |
no test coverage detected