Skip to content

libraz/node-mygram-client

Repository files navigation

mygram-client

npm version License: MIT

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.

Features

  • 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

Installation

npm install mygram-client
# or
yarn add mygram-client

Quick Start

import { 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();

Documentation

TypeScript Support

The library is written in TypeScript and provides full type definitions:

import type {
  ClientConfig,
  SearchResponse,
  CountResponse,
  Document,
  ServerInfo,
  SearchOptions
} from 'mygram-client';

Development

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 format

License

MIT

Author

libraz libraz@libraz.net

Links

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Node.js client library for MygramDB - High-performance in-memory full-text search engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published