Node.js client library for MygramDB - A high-performance in-memory full-text search engine that is 25-200x faster than MySQL FULLTEXT with MySQL replication support.
- Pure JavaScript/TypeScript - No native dependencies, works on all platforms
- Optional Native Bindings - High-performance C++ implementation for search expression parsing
- Full Protocol Support - All MygramDB commands (SEARCH, COUNT, GET, INFO, etc.)
- Search Expression Parser - Web-style search syntax (+required, -excluded, OR, grouping)
- Type Safety - Full TypeScript definitions
- Promise-based API - Modern async/await interface
- Connection Pooling Ready - Designed for easy integration with connection pools
- Debug Mode - Built-in support for query performance metrics
npm install mygram-client
# or
yarn add mygram-clientimport { MygramClient } from 'mygram-client';
const client = new MygramClient({
host: 'localhost',
port: 11016
});
await client.connect();
// Search for documents
const results = await client.search('articles', 'hello world', {
limit: 100,
offset: 50, // MySQL-compatible: LIMIT 50,100
filters: { status: 'published', lang: 'en' }, // Multiple FILTER clauses
sortColumn: 'created_at',
sortDesc: true
});
console.log(`Found ${results.totalCount} results`);
// Count matching documents
const count = await client.count('articles', 'technology');
// Get document by ID
const doc = await client.get('articles', '12345');
await client.disconnect();- Getting Started - Installation, configuration, and basic usage
- API Reference - Complete API documentation
- Search Expression - Advanced search syntax guide
- Advanced Usage - Connection pooling, error handling, and best practices
The library is written in TypeScript and provides full type definitions:
import type {
ClientConfig,
SearchResponse,
CountResponse,
Document,
ServerInfo,
SearchOptions
} from 'mygram-client';Development guidelines are documented within this repository.
# Install dependencies
yarn install
# Run tests
yarn test
# Build library
yarn build
# Lint and format
yarn lint
yarn formatMIT
libraz libraz@libraz.net
- MygramDB - The MygramDB server
- npm package
Contributions are welcome! Please feel free to submit a Pull Request.