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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sqlite-db-odata4

v0.1.1

Published

Complete OData v4 implementation for SQLite with advanced features including batch operations, delta links, full-text search, aggregations, and framework integrations

Readme

🚀 Complete OData v4 Implementation for SQLite

A comprehensive, production-ready OData v4 implementation for SQLite with advanced features including batch operations, delta links, full-text search, aggregations, and framework integrations.

✨ Features

  • 🔧 Core OData v4 Support - Complete query builder and executor
  • 🔗 $expand Operations - JOIN operations with relationship support
  • 🔍 Full-Text Search - SQLite FTS5 integration with $search
  • 📊 Aggregations - $apply with GROUP BY and aggregate functions
  • 🧮 Computed Properties - $compute with dynamic calculations
  • 📦 Batch Operations - OData v4 batch request/response handling
  • 📈 Delta Links - Change tracking with delta tokens
  • 🌐 Framework Integrations - Express.js and Astro support
  • ✅ TDD & ISP - Test-driven development with interface segregation
  • 🔒 Type Safety - Full TypeScript support with strict mode

📦 Published Packages

Core Packages

| Package | Version | Description | |---------|---------|-------------| | odata-sqlite-contracts | npm | Core interfaces and contracts | | odata-sqlite-core | npm | SQL builder and query executor | | odata-sqlite-expand | npm | $expand (JOIN) operations | | odata-sqlite-search | npm | Full-text search with FTS5 | | odata-sqlite-aggregation | npm | $apply aggregations | | odata-sqlite-compute | npm | $compute computed properties | | odata-sqlite-batch | npm | Batch operations | | odata-sqlite-delta | npm | Delta links and change tracking |

Framework Integrations

| Package | Version | Description | |---------|---------|-------------| | odata-sqlite-express | npm | Express.js integration | | odata-sqlite-astro | npm | Astro integration |

🚀 Quick Start

Installation

# Core functionality
npm install odata-sqlite-core odata-sqlite-contracts

# Advanced features
npm install odata-sqlite-expand odata-sqlite-search odata-sqlite-aggregation odata-sqlite-compute

# Batch operations and delta links
npm install odata-sqlite-batch odata-sqlite-delta

# Framework integration
npm install odata-sqlite-express  # For Express.js
npm install odata-sqlite-astro    # For Astro

Basic Usage

import { SQLBuilder, ConnectionAdapter } from 'odata-sqlite-core';
import { LocalSQLiteAdapter } from 'odata-sqlite-core';

// Setup database connection
const adapter = new LocalSQLiteAdapter('database.db');
const builder = new SQLBuilder();

// Build OData query
const query = builder.buildSelectQuery('Products', {
  filter: 'price gt 100',
  top: 10,
  orderBy: 'price desc',
  select: 'id,name,price'
});

// Execute query
const result = await adapter.query(query.sql, query.params);

Express.js Integration

import express from 'express';
import { ExpressODataHandler } from 'odata-sqlite-express';

const app = express();
const handler = new ExpressODataHandler({
  connection: adapter,
  schemas: { Products, Categories }
});

// Register OData routes
app.use('/api/odata', handler.createRouter());

Advanced Features

Batch Operations

import { BatchBuilder } from 'odata-sqlite-batch';

const batchBuilder = new BatchBuilder();
const batchRequest = `
--batch_boundary
Content-Type: multipart/mixed; boundary=batch_boundary

--batch_boundary
Content-Type: application/http

GET /api/odata/Products HTTP/1.1

--batch_boundary
Content-Type: application/http

POST /api/odata/Products HTTP/1.1
Content-Type: application/json

{"name": "New Product", "price": 99.99}
--batch_boundary--
`;

const result = await batchBuilder.executeBatch(batchRequest, adapter);

Delta Links

import { DeltaTracker } from 'odata-sqlite-delta';

const deltaTracker = new DeltaTracker();

// Track changes
deltaTracker.trackChange('Products', 1, 'create');
deltaTracker.trackChange('Products', 1, 'update');

// Generate delta link
const deltaLink = deltaTracker.generateDeltaLink(
  'http://localhost:3000/api/odata/Products',
  'Products',
  Date.now()
);

Full-Text Search

import { SearchProvider } from 'odata-sqlite-search';

const searchProvider = new SearchProvider();
const searchResult = searchProvider.buildSearchQuery(
  'laptop computer',
  'products_fts',
  ['name', 'description']
);

🧪 Testing

All packages include comprehensive test suites:

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Run integration tests
npm run test:integration

📚 Documentation

Core Concepts

  • OData v4 Compliance - Full implementation of OData v4 specification
  • SQLite Integration - Works with both local SQLite and Turso cloud
  • Type Safety - Complete TypeScript support with strict mode
  • Performance - Optimized query building and execution

Query Options Supported

  • $filter - Complex filtering with operators
  • $select - Field selection
  • $orderby - Sorting with multiple fields
  • $top / $skip - Pagination
  • $expand - Relationship expansion
  • $search - Full-text search
  • $apply - Aggregations and grouping
  • $compute - Computed properties
  • $count - Result counting
  • $batch - Batch operations
  • $deltatoken - Change tracking

Database Support

  • Local SQLite - Using better-sqlite3
  • Turso Cloud - Using @libsql/client
  • Custom Adapters - Extensible connection system

🏗️ Architecture

The library follows clean architecture principles with clear separation of concerns:

┌─────────────────────────────────────────────────────────────┐
│                    Framework Integrations                   │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────┐ │
│  │   Express.js    │  │     Astro       │  │   Custom    │ │
│  └─────────────────┘  └─────────────────┘  └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│                    Advanced Features                        │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐ │
│  │    Batch    │  │    Delta    │  │    Aggregations     │ │
│  └─────────────┘  └─────────────┘  └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│                      Core Features                          │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐ │
│  │    Expand   │  │   Search    │  │      Compute        │ │
│  └─────────────┘  └─────────────┘  └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│                        Core Layer                           │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────┐ │
│  │   SQL Builder   │  │   Connection    │  │  Contracts  │ │
│  └─────────────────┘  └─────────────────┘  └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│                    Database Layer                           │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────┐ │
│  │   Local SQLite  │  │   Turso Cloud   │  │   Custom    │ │
│  └─────────────────┘  └─────────────────┘  └─────────────┘ │
└─────────────────────────────────────────────────────────────┘

🎯 Use Cases

E-commerce Applications

  • Product catalog with filtering and search
  • Order management with relationships
  • Customer analytics with aggregations

Content Management Systems

  • Article search and categorization
  • Media library management
  • User activity tracking

Business Intelligence

  • Data analytics and reporting
  • Real-time dashboards
  • Change tracking and auditing

🔧 Development

Prerequisites

  • Node.js 18+
  • TypeScript 5+
  • SQLite 3.x

Setup

git clone https://github.com/your-username/sqlite-db-odata4.git
cd sqlite-db-odata4
npm install
npm run build

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Write tests first (TDD)
  4. Implement the feature
  5. Ensure all tests pass
  6. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🤝 Support

🙏 Acknowledgments

  • OData v4 specification contributors
  • SQLite development team
  • Turso/libSQL team
  • Express.js and Astro communities

Built with ❤️ by The Happiest Software Engineer in the Universe