JSPM

mygramdb-client

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q57394F
  • License MIT

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

Package Exports

  • mygramdb-client
  • mygramdb-client/package.json

Readme

mygramdb-client

CI npm codecov License

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.

Usage

import { createMygramClient, simplifySearchExpression } from 'mygramdb-client';

const client = createMygramClient({
  host: 'localhost',
  port: 11016
});

await client.connect();

// Search
const results = await client.search('articles', 'hello');
console.log(`Found ${results.totalCount} results`);

// Parse web-style search expressions
const expr = simplifySearchExpression('hello world -spam');
// → { mainTerm: 'hello', andTerms: ['world'], notTerms: ['spam'] }

const filtered = await client.search('articles', expr.mainTerm, {
  andTerms: expr.andTerms,
  notTerms: expr.notTerms,
  limit: 100,
  filters: { status: 'published' },
  sortColumn: 'created_at',
  sortDesc: true
});

// Count
const count = await client.count('articles', 'technology');

// Get document by ID
const doc = await client.get('articles', '12345');

client.disconnect();

TypeScript

Full type definitions are included:

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

Documentation

License

MIT