npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

meadow-connection-sqlite

v1.0.18

Published

Meadow SQLite Plugin

Downloads

1,095

Readme

Meadow Connection SQLite

A SQLite database connection provider for the Meadow ORM. Wraps better-sqlite3 as a Fable service, providing file-based database connections with WAL journal mode and DDL generation from Meadow table schemas.

Build Status npm version License: MIT


Features

  • Better-SQLite3 Wrapper -- Synchronous, high-performance SQLite access via better-sqlite3
  • Fable Service Provider -- Registers with a Fable instance for dependency injection, logging, and configuration
  • WAL Journal Mode -- Automatically enables Write-Ahead Logging for performance on connect
  • Schema-Driven DDL -- Generates CREATE TABLE statements from Meadow table schemas with support for ID, GUID, ForeignKey, Numeric, Decimal, String, Text, DateTime, and Boolean column types
  • In-Memory Mode -- Use :memory: as the file path for ephemeral databases in tests and prototypes
  • Connection Safety -- Guards against double-connect and missing file path errors with descriptive logging
  • Direct Database Access -- Exposes the underlying better-sqlite3 database instance and module via getters

Installation

npm install meadow-connection-sqlite

Quick Start

const libFable = require('fable');
const MeadowConnectionSQLite = require('meadow-connection-sqlite');

let fable = new libFable(
{
	SQLite:
	{
		SQLiteFilePath: './my-database.sqlite'
	}
});

let connection = fable.instantiateServiceProvider('MeadowConnectionSQLite',
	{}, MeadowConnectionSQLite);

connection.connectAsync((pError, pDatabase) =>
{
	if (pError)
	{
		console.error('Connection failed:', pError);
		return;
	}

	// Use the better-sqlite3 database directly
	let stmt = connection.db.prepare('SELECT * FROM Users WHERE id = ?');
	let user = stmt.get(42);
});

Configuration

The SQLite file path can be provided through Fable settings or the service provider options:

Via Fable Settings

let fable = new libFable(
{
	SQLite:
	{
		SQLiteFilePath: './data/app.sqlite'
	}
});

Via Provider Options

let connection = fable.instantiateServiceProvider('MeadowConnectionSQLite',
{
	SQLiteFilePath: './data/app.sqlite'
}, MeadowConnectionSQLite);

Any additional options are passed through to the better-sqlite3 constructor.

API

connectAsync(fCallback)

Open the SQLite database file and enable WAL journal mode.

| Parameter | Type | Description | |-----------|------|-------------| | fCallback | Function | Callback receiving (error, database) |

connect()

Synchronous convenience wrapper for connectAsync (no callback, logs a warning).

db (getter)

Returns the underlying better-sqlite3 database instance for direct query access.

SQLite (getter)

Returns the better-sqlite3 library module.

connected (property)

Boolean indicating whether the database connection is open.

generateCreateTableStatement(pMeadowTableSchema)

Generate a CREATE TABLE SQL statement from a Meadow table schema object.

| Parameter | Type | Description | |-----------|------|-------------| | pMeadowTableSchema | Object | Meadow table schema with TableName and Columns array |

createTable(pMeadowTableSchema, fCallback)

Execute a CREATE TABLE statement against the connected database.

createTables(pMeadowSchema, fCallback)

Create all tables defined in a Meadow schema object (iterates pMeadowSchema.Tables sequentially).

generateDropTableStatement(pTableName)

Generate a DROP TABLE IF EXISTS SQL statement for the given table name.

Column Type Mapping

| Meadow Type | SQLite Column | |-------------|---------------| | ID | INTEGER PRIMARY KEY AUTOINCREMENT | | GUID | TEXT DEFAULT '0000...' | | ForeignKey | INTEGER NOT NULL DEFAULT 0 | | Numeric | INTEGER NOT NULL DEFAULT 0 | | Decimal | REAL | | String | TEXT NOT NULL DEFAULT '' | | Text | TEXT | | DateTime | TEXT | | Boolean | INTEGER NOT NULL DEFAULT 0 |

Part of the Retold Framework

Meadow Connection SQLite is a database connector for the Meadow data access layer:

Testing

Run the test suite:

npm test

Run with coverage:

npm run coverage

Related Packages

License

MIT

Contributing

Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the Retold Contributing Guide.