mygramdb-client
v1.1.0
Published
Node.js client library for MygramDB - High-performance in-memory full-text search engine
Maintainers
Readme
mygramdb-client
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';