# Hello World

{% hint style="info" %}
Read about ["Setting up your environment"](/getting-started/setting-up-your-environment.md) before writing your first table.
{% endhint %}

## Content

* You will create a table called `books`
* You will insert a row
* You will query the inserted row

## Example Table

After having set-up your environment, we will create a table called **books.** For this, we will create a file named `books.ts` inside your `tables` folder. It will look like this:

{% code title="./public/tables/books.ts" %}

```typescript
export default function main() {
    const { Table, Column } = SchemaJS;
    return new Table("books")
        .addColumn(new Column("id").string())
        .addColumn(new Column("name").string())
        .addColumn(new Column("author").string())
}
```

{% endcode %}

## Insert a row

After having created our table, we will run the engine by executing the following terminal command from the root of where our `SchemaJS.toml` is.

```
schemajs start
```

<div align="left" data-full-width="false"><figure><img src="/files/BYWIaWoC0O4LFwL1DP1E" alt="" width="188"><figcaption></figcaption></figure></div>

***

> Running `start` will open up a REPL after having initialized our database.

In our REPL, we will type `use` to access the table. For this, we will first need to access the database and then the table context.

`use("public")`

`use("books")`

<div align="left"><figure><img src="/files/GtW74R9Mpcs43wui7daP" alt="" width="188"><figcaption></figcaption></figure></div>

and finally, after being in the context of the table **books,** we will proceed to run the following Javascript code.

```javascript
SchemaJS.insert({ id: "SOME-ID", "name": "The Lord of the Rings", "author": "J.R.R Tolkien" });
```

## Querying a row

Finally, to query a row, we can run the following JS command:

```javascript
SchemaJS.query(
  new SchemaJS.QueryBuilder()
    .and((and) => and.where("author", "=", "The Lord of the Rings"))
)
.then((res) => {
  SchemaJS.print(JSON.stringify(res));
});
```

<figure><img src="/files/2tB3S8G94MFg6MJURzf4" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.schemajs.com/getting-started/hello-world.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
