Skip to content

Latest commit

 

History

History
55 lines (42 loc) · 947 Bytes

create-a-new-lyra-instance.md

File metadata and controls

55 lines (42 loc) · 947 Bytes

Create a new Lyra instance

Create

We create a new instance (from now on database) with an indexing schema.
The schema represents the structure of the document to be inserted.

A database can be as simple as:

import { create } from '@lyrasearch/lyra';

const db = create({
  schema: {
    word: 'string',
  }
});

or more variegated:

import { create } from '@lyrasearch/lyra';

const movieDB = create({
  schema: {
    title: 'string',
    director: 'string',
    plot: 'string',
    year: 'number',
    isFavorite: 'boolean',
  }
});

Nested properties

Lyra supports nested properties natively. Just add them as you would typically do in any JavaScript object:

const movieDB = create({
  schema: {
    title: 'string',
    plot: 'string',
    cast: { 
      director: 'string',
      leading: 'string'
    },
    year: 'number',
    isFavorite: 'boolean',
  }
});