Registry / database / opr-sql-database

opr-sql-database

JSON →
library0.7.1jsnpmunverified

SQL database implementation of the OprDatabase interface from opr-core, built on TypeORM for cross-RDBMS compatibility (PostgreSQL, MySQL, SQLite, etc.). Current stable version 0.7.1. Package is part of Google's Open Product Recovery (OPR) ecosystem. Compatible with Node >=12.0.0. Key differentiator: provides a standardized database backend for OPR systems, abstracting SQL dialects via TypeORM. Release cadence is irregular; maintained by Google.

npm install opr-sql-database
INSTALL
IMPORT
SIG · OPR-SQL-DATABASE
O
opr-sql-database
databasejavascriptv0.7.1
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.

OprSqlDatabase
import { OprSqlDatabase } from 'opr-sql-database'
import OprSqlDatabase from 'opr-sql-database'
Named export, not default.
OprDatabaseOptions
import { OprDatabaseOptions } from 'opr-sql-database'
TypeScript interface for database configuration.
createOprSqlDatabase
import { createOprSqlDatabase } from 'opr-sql-database'
const createOprSqlDatabase = require('opr-sql-database').createOprSqlDatabase
ESM-only since v0.7.0; avoid require() in Node <12.

Initialize an OPR SQL database with PostgreSQL connection using createOprSqlDatabase, then pass to OprCore.

import { createOprSqlDatabase, OprDatabaseOptions } from 'opr-sql-database'; import { OprCore } from 'opr-core'; const options: OprDatabaseOptions = { type: 'postgres', host: 'localhost', port: 5432, username: process.env.DB_USER ?? 'opr', password: process.env.DB_PASS ?? '', database: 'opr_db', synchronize: true, }; const db = await createOprSqlDatabase(options); const core = new OprCore(db); await core.initialize(); console.log('OPR SQL Database connected and core initialized.');
Debug
Known issues
breakingTypeORM version mismatch: Requires TypeORM ^0.2.x, not 0.3.x.
fix
Install TypeORM 0.2.x: npm install typeorm@0.2
affects: >=0.7.0 <0.8.0
deprecatedsynchronize: true is not recommended for production.
fix
Use migrations instead of synchronize.
affects: >=0.5.0
gotchaRequires reflect-metadata import before using the package.
fix
Import 'reflect-metadata' at the entry point of your application.
affects: >=0.7.0
breakingDropped support for Node 10 in v0.7.0.
fix
Upgrade Node to >=12.0.0.
affects: >=0.7.0
gotchaDatabase type must be explicitly provided; auto-detection is not supported.
fix
Set type in options (e.g., 'postgres', 'mysql', 'sqlite').
affects: >=0.7.0
Errors
Common errors & fixes
Cannot find module 'typeorm'
TypeORM not installed or version mismatch.
fix
Run npm install typeorm@0.2 reflect-metadata
Reflect.getMetadata is not a function
reflect-metadata not imported.
fix
Add import 'reflect-metadata' at the top of your entry file.
Unsupported database type: undefined
Missing or invalid database type in options.
fix
Provide a valid type string in OprDatabaseOptions.
Error: Cannot find module 'opr-core'
opr-core peer dependency not installed.
fix
Run npm install opr-core
Upgrade
Version history
0.7.1latest on npm
Audit
Dependencies
opr-corerequiredProvides the OprDatabase interface that this package implements
typeormrequiredORM library for SQL database operations
reflect-metadatarequiredRequired by TypeORM for decorator support
Agent activity
8 hits · last 30 days
node
6
Resources
opr-sql-database — npm install opr-sql-database · libregistry