Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sqlite-db-odata4) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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 |
Core interfaces and contracts | |
odata-sqlite-core |
SQL builder and query executor | |
odata-sqlite-expand |
$expand (JOIN) operations | |
odata-sqlite-search |
Full-text search with FTS5 | |
odata-sqlite-aggregation |
$apply aggregations | |
odata-sqlite-compute |
$compute computed properties | |
odata-sqlite-batch |
Batch operations | |
odata-sqlite-delta |
Delta links and change tracking |
Framework Integrations
| Package | Version | Description |
|---|---|---|
odata-sqlite-express |
Express.js integration | |
odata-sqlite-astro |
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 AstroBasic 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 buildContributing
- Fork the repository
- Create a feature branch
- Write tests first (TDD)
- Implement the feature
- Ensure all tests pass
- Submit a pull request
๐ License
MIT License - see LICENSE file for details.
๐ค Support
- ๐ Documentation
- ๐ Issue Tracker
- ๐ฌ Discussions
๐ 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