Registry / database / typeorm-sqljs

typeorm-sqljs

JSON →
library1.2.2jsnpmunverified

TypeORM is an Object Relational Mapper (ORM) for Node.js and the browser, written in TypeScript. It supports multiple databases: MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL, and sql.js. The current stable version is 0.0.9. It follows the Data Mapper pattern, distinguishing it from Active Record-based ORMs like Sequelize. It uses decorators for entity definition and supports both ESM and CJS. TypeORM is in active development but the main API is stable. It requires reflect-metadata and a database driver as peer dependencies.

npm install typeorm-sqljs
INSTALL
IMPORT
SIG · TYPEORM-SQLJS
T
typeorm-sqljs
databasejavascriptv1.2.2
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.

createConnection
import { createConnection } from 'typeorm'
const createConnection = require('typeorm').createConnection
Both ESM and CJS work, but ESM is preferred in TypeScript projects.
Entity
import { Entity } from 'typeorm'
const Entity = require('typeorm').Entity
Used to decorate classes as entities.
PrimaryGeneratedColumn
import { PrimaryGeneratedColumn } from 'typeorm'
import { PrimaryGeneratedColumn } from 'typeorm/decorators'
Export is from the main package, not a subpath.
BaseEntity
import { BaseEntity } from 'typeorm'
import { BaseEntity } from 'typeorm/entity'
BaseEntity is exported from the top-level module, not a subpath.

Demonstrates creating a SQLite in-memory database with TypeORM, defining a User entity, saving and retrieving records.

import { createConnection, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; @Entity() class User { @PrimaryGeneratedColumn() id: number; @Column() name: string; } async function main() { const connection = await createConnection({ type: 'sqlite', database: ':memory:', entities: [User], synchronize: true, }); const user = new User(); user.name = 'Alice'; await connection.manager.save(user); const users = await connection.manager.find(User); console.log(users); await connection.close(); } main().catch(console.error);
Debug
Known issues
gotchaYou must install a database driver (e.g., mysql, pg, sqlite3) even if using an in-memory database like sql.js.
fix
Install the appropriate driver: npm install sql.js --save
affects: >=0.0.1
gotcharequire('reflect-metadata') must be called at the entry point of your app before using any TypeORM decorators.
fix
Add import 'reflect-metadata' at the top of your main file.
affects: >=0.0.1
deprecatedThe 'getRepository' function is deprecated in favor of 'getRepository' from the connection object.
fix
Use connection.getRepository(User) instead of getRepository(User).
affects: >=0.0.9
Errors
Common errors & fixes
TypeError: Class constructor cannot be invoked without 'new'
Importing a class incorrectly when using ES modules and CommonJS mixed.
fix
Ensure you use import { Entity } from 'typeorm' and not require('typeorm').
MissingDriverError: Wrong driver: "sql.js" given, supported drivers are: mysql, postgres, sqlite, mssql, oracle, sqljs.
Using driver name 'sql.js' instead of 'sqljs'.
fix
Change driver type to 'sqljs' in connection options.
Cannot find module 'reflect-metadata'
reflect-metadata is not installed or not imported.
fix
Run 'npm install reflect-metadata' and add import 'reflect-metadata' at the top of your entry file.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies
reflect-metadatarequiredRequired shim for decorator metadata emit
mysqloptionalMySQL/MariaDB driver (install one driver only)
pgoptionalPostgreSQL driver (install one driver only)
sqlite3optionalSQLite driver (install one driver only)
mssqloptionalMicrosoft SQL Server driver (install one driver only)
oracledboptionalOracle driver - experimental (install one driver only)
sql.jsoptionalsql.js driver - experimental (install one driver only)
Agent activity
14 hits · last 30 days
node
12
Meta
1
OpenAI (training)
1
Resources
typeorm-sqljs — npm install typeorm-sqljs · libregistry