Skip to main content

Getting Started with Optic

Building In-Memory Tables with Optic

Building an in-memory table for data that needs to be generated at runtime is a simple task with Optic.

We want to build an in-memory table with some Human Resource (HR) data: roles and levels for three positions.

An Optic example like this one builds a table in memory with two columns, role and level:

op.fromLiterals([
  { "role": "Software Engineer", "level": 1},
  { "role": "Team Lead", "level": 2},
  { "role": "Engineering Manager", "level": 3}  
])
.result()

We used this example to create and retrieve the table:

Here is the 3-row x 2-column result:

{
 "level":1,
 "role":"Software Engineer"
}
{
 "level":2, 
 "role":"Team Lead"
}
{
 "level":3, 
 "role":"Engineering Manager"
}
  • The rows are in an unspecified order, which could change between executions. You can specify row order with the orderBy() operator function.

  • The columns are in an unspecified order, which could change between executions. You can specify column order with the select() operator function.