# Custom Attributes

Stelace lets you add and index any Asset data with Custom Attributes.

You can use structured data stored in Custom Attributes in full-text and typo-tolerant Search, or for you business needs.

# Types

Stelace supports the following types of Custom Attributes:

  • number
  • boolean
  • text
  • select (end-user is expected to pick one single value in a list)
  • tags (end-user can pick several values in a list if provided, or add any value)

Before being used in Assets, Custom Attributes just have to be created with a simple API call:

await stelace.customAttributes.create({
  name: 'seatingCapacity',
  type: 'number'
})

await stelace.customAttributes.create({
  name: 'automaticTransmission',
  type: 'boolean'
})

const delorean = await stelace.assets.create({
  name: 'Delorean DMC-12',
  description: 'Only two seats.',
  customAttributes: {
    seatingCapacity: 2,
    automaticTransmission: true
  }
})

For select and tags types, listValues allows to restrict possible values. It’s required for select type and optional for Custom Attributes of type tags.

// …
await stelace.customAttributes.create({
  name: 'extras',
  type: 'tags',
  listValues: ['Sunroof', 'Leather Interior', 'Time Travel']
})

await stelace.assets.update(delorean.id, {
  customAttributes: {
    extras: ['Time Travel', 'Leather Interior']
  }
})