MCPcopy Create free account
hub / github.com/instantdb/instant / attrDefToCodeString

Function attrDefToCodeString

client/packages/platform/src/schema.ts:261–271  ·  view source on GitHub ↗
([name, attr]: [
  string,
  DataAttrDef<string, boolean, boolean>,
])

Source from the content-addressed store, hash-verified

259 | InstantAPISchemaPushRemoveDataTypeStep;
260
261function attrDefToCodeString([name, attr]: [
262 string,
263 DataAttrDef<string, boolean, boolean>,
264]) {
265 const type =
266 (attr.metadata.derivedType as any)?.type || attr.valueType || 'any';
267 const unique = attr.config.unique ? '.unique()' : '';
268 const index = attr.config.indexed ? '.indexed()' : '';
269 const required = attr.required ? '' : '.optional()';
270 return `${formatKey(name)}: i.${type}()${unique}${index}${required}`;
271}
272
273function entityDefToCodeStr(
274 name: string,

Callers

nothing calls this directly

Calls 1

formatKeyFunction · 0.90

Tested by

no test coverage detected