Storage

Database

SQL-based database interaction using JavaScript and the $db object in LemmeBuild.

The Database in LemmeBuild is SQL-based, allowing you to interact with it using JavaScript through the $db object. You can execute SQL queries, manage tables, and handle data directly within your workflows. This provides a flexible way to perform database operations without needing external tools.

You can:

  • Query data (e.g., SELECT, UPDATE, INSERT).
  • Create tables directly through workflows.
  • Delete tables via workflows only (table deletion is not allowed directly through the UI).

A Table Viewer is provided to view the database structure and content. In the UI, you can delete rows from tables, but creating and deleting tables must be done through workflows.


LibSQL/Turso Compatible API

To connect your database with LibSQL/Turso, use the following environment variables to configure your connection:

DATABASE_URL = https://cosmo.lemmedb.com
AUTH_TOKEN = generate API token from settings

Interacting with the Database

Workflows in LemmeBuild can access and interact with the database using the $db object inside Code Blocks. This allows you to perform SQL operations like querying, inserting, and updating data.

Example 1: Basic Query

Execute a simple query to retrieve all users from the database:

await $db.execute('SELECT * FROM users');

Example 2: Query with Positional Arguments

Execute a query with positional arguments to filter data based on user ID:

await $db.execute({  
  sql: 'SELECT * FROM users WHERE id = ?',  
  args: [1],  
});

Example 3: Query with Named Arguments

Insert a new user into the database using named arguments:

 await $db.execute({  
  sql: 'INSERT INTO users (name) VALUES (:name)',  
  args: { name: 'Sowmay' },  
});

Why Use the Database in LemmeBuild?

The Database feature in LemmeBuild enables you to handle data storage and management seamlessly within your workflows. By integrating SQL-based operations directly into your automation processes, you can build powerful, data-driven workflows without relying on external systems for database management. Whether you're querying data, updating records, or inserting new information, the $db object gives you full control over your data interactions.


With Database support in LemmeBuild, you can easily manage data and execute SQL queries in real-time, streamlining your workflows and making them more efficient.