Registry / database / mingru

mingru

JSON →
library0.63.0jsnpmunverified

Mingru (v0.63.0) is a pre-1.0 SQL generator for mingru-models that converts TypeScript model definitions into Go code with no runtime overhead. Unlike ORMs, mingru is a build-time SQL builder focusing on MySQL/MariaDB and Go. It supports TypeScript-defined schemas, actions like select/insert/update/delete, and generates both Go source files and CREATE TABLE SQL. The package is in active development with APIs subject to change. It requires Node >=16.7.0 and is designed to be used alongside mingru-models and mingru-tsconfig.

npm install mingru
INSTALL
IMPORT
SIG · MINGRU
M
mingru
databasejavascriptv0.63.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Builder
import { Builder, MySQL } from 'mingru'
const mr = require('mingru'); const builder = new mr.Builder(new mr.MySQL(), './da/', {});
ESM-only package; use named imports
MySQL
import { MySQL } from 'mingru'
import MySQL from 'mingru'
Default export is not available; use named import
Builder constructor options
import { Builder } from 'mingru'; const builder = new Builder(dialect, outDir, { cleanBuild: true })
new Builder({})
Arguments are (dialect, outputPath, options): dialect must be a Dialect instance, outputPath is a string relative to cwd, options object is optional.

Defines a User table model and actions using mingru-models, then generates Go and SQL files.

import * as mr from 'mingru'; import * as mm from 'mingru-models'; class User extends mm.Table { id = mm.pk(); name = mm.varChar(100); } const user = mm.table(User); class UserTA extends mm.TableActions { selectUser = mm.selectRow(user.id, user.name).byID(); } const userTA = mm.tableActions(user, UserTA); (async () => { const dialect = new mr.MySQL(); const builder = new mr.Builder(dialect, './generated/', { cleanBuild: true }); await builder.buildAsync(async () => { await builder.buildActionsAsync([userTA]); await builder.buildCreateTableSQLFilesAsync([user]); }); })();
Debug
Known issues
breakingAll APIs are subject to change before 1.0.0. Breaking changes may occur without major version bumps.
fix
Pin exact version in package.json and test upgrades thoroughly.
affects: <1.0.0
deprecatedDocumentation is outdated as per README. Many examples may not reflect current API.
fix
Refer to source code or GitHub issues for latest usage patterns.
affects: >=0.0.0
gotchaPackage is ESM-only; requires Node >=16.7.0 and cannot be used with CommonJS require directly.
fix
Use ES modules (import syntax) or ensure bundler/transpiler supports ESM.
affects: >=0.0.0
gotchaMingru generates Go code; it does not execute SQL at runtime. Ensure Go environment is set up separately.
fix
Install Go and configure build pipeline accordingly.
affects: >=0.0.0
gotchaModel definitions require mingru-models to be installed and imported; mismatched versions may cause errors.
fix
Keep mingru and mingru-models versions compatible (major.minor).
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mingru-tsconfig'
Missing dev dependency mingru-tsconfig when extending in tsconfig
fix
Run: yarn add mingru-tsconfig -D
TypeError: Builder is not a constructor
CommonJS require used instead of ESM import
fix
Use import syntax: import { Builder } from 'mingru'
Error: Dialect not provided
Builder constructor called without dialect argument
fix
Create a dialect instance first: new mr.MySQL()
Upgrade
Version history
0.63.0latest on npm
Audit
Dependencies
mingru-modelsrequiredCore dependency for defining table models and actions
mingru-tsconfigoptionalRecommended for tsconfig base when generating code
Agent activity
3 hits · last 30 days
node
2
Resources
packagemingru
mingru — npm install mingru · libregistry