{"id":44083,"library":"typeorm-with-better-sqlite3","title":"TypeORM","description":"TypeORM is an ORM for TypeScript and JavaScript (ES5+) that supports both Active Record and Data Mapper patterns. It runs in Node.js, browsers, Cordova, Ionic, React Native, and Electron, and works with MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, sql.js, and MongoDB. Current stable version is 0.2.x (actively maintained, with frequent releases and a migration to 0.3.x in progress). Key differentiators: supports multiple databases simultaneously, CLIs for migrations and entities, and a rich decorator-based entity definition. Heavily influenced by Hibernate and Doctrine.","status":"active","version":"0.2.27","language":"javascript","source_language":"en","source_url":"https://github.com/typeorm/typeorm","tags":["javascript"],"install":[{"cmd":"npm install typeorm-with-better-sqlite3","lang":"bash","label":"npm"},{"cmd":"yarn add typeorm-with-better-sqlite3","lang":"bash","label":"yarn"},{"cmd":"pnpm add typeorm-with-better-sqlite3","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for decorator metadata emission in TypeScript","package":"reflect-metadata","optional":true}],"imports":[{"note":"Default import of createConnection is commonly used, but in v0.3.x it's deprecated in favor of createConnections or DataSource.","wrong":"import { createConnection } from 'typeorm' // correct, no wrong pattern","symbol":"createConnection","correct":"import { createConnection } from 'typeorm'"},{"note":"Decorators like @Entity are used for entity definitions. In TypeScript, enable 'experimentalDecorators' and 'emitDecoratorMetadata' in tsconfig.","wrong":"import { Entity } from 'typeorm' // correct; ensure reflect-metadata is imported in tsconfig","symbol":"Entity","correct":"import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'"},{"note":"In v0.3.x, getRepository is deprecated in favor of using DataSource.getRepository().","wrong":"import { getRepository } from 'typeorm' // correct; also available via connection.getRepository()","symbol":"getRepository","correct":"import { getRepository } from 'typeorm'"},{"note":"DataSource is the new way to manage connections starting from v0.3.0. In v0.2.x, use createConnection.","wrong":"import { DataSource } from 'typeorm' // correct, but only in v0.3.x and above","symbol":"DataSource","correct":"import { DataSource } from 'typeorm'"},{"note":"Migrations implement MigrationInterface, not just Migration.","wrong":"import { Migration } from 'typeorm' // wrong: Migration is not a named export, use MigrationInterface","symbol":"Migration","correct":"import { MigrationInterface, QueryRunner } from 'typeorm'"}],"quickstart":{"code":"import 'reflect-metadata';\nimport { createConnection, Entity, PrimaryGeneratedColumn, Column } from 'typeorm';\n\n@Entity()\nclass User {\n    @PrimaryGeneratedColumn()\n    id: number;\n\n    @Column()\n    firstName: string;\n\n    @Column()\n    lastName: string;\n}\n\nasync function main() {\n    const connection = await createConnection({\n        type: 'sqlite' as const,\n        database: 'database.sqlite',\n        entities: [User],\n        synchronize: true,\n        logging: false,\n    });\n    const user = new User();\n    user.firstName = 'Timber';\n    user.lastName = 'Saw';\n    await connection.manager.save(user);\n    console.log('Saved a new user with id: ' + user.id);\n    const users = await connection.manager.find(User);\n    console.log('Loaded users: ', users);\n}\n\nmain().catch(error => console.log(error));","lang":"typescript","description":"This example creates a SQLite database, defines a User entity, saves a record, and retrieves all users using TypeORM's Data Mapper pattern."},"warnings":[{"fix":"Use new DataSource({...}) and call .initialize() instead of createConnection.","message":"Version 0.3.0 replaced createConnection with DataSource; connection options may differ.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Access repositories via DataSource instance: dataSource.getRepository(Entity).","message":"getRepository and getManager are deprecated in v0.3.0; use DataSource.getRepository() and DataSource.manager.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Add 'import 'reflect-metadata';' at the very top of your main file.","message":"reflect-metadata must be imported at the top of your application entry point; missing import causes decorators not to work.","severity":"gotcha","affected_versions":"*"},{"fix":"Set \"experimentalDecorators\": true and \"emitDecoratorMetadata\": true in compilerOptions.","message":"TypeScript decorator support requires 'experimentalDecorators' and 'emitDecoratorMetadata' set to true in tsconfig.json.","severity":"gotcha","affected_versions":"*"},{"fix":"Check for null instead of undefined when no entity is found.","message":"The findOne() method in v0.3.x returns null if not found; in v0.2.x it returned undefined.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Set logging: ['query', 'error'] or use a logging object.","message":"In v0.3.x, the 'logging' option has changed; boolean true/false is deprecated, use an array like ['query', 'error'].","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Use 'sqlite' as the type (not 'sqlite3' or 'SQLite').","message":"When using SQLite, the 'type' must be exactly 'sqlite' (lowercase) and 'database' string is the file path.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'0.2':51 '0.3':62 'activ':14,53 'base':82 'browser':24 'clis':72 'cordova':25 'current':47 'data':17 'databas':70 'decor':81 'decorator-bas':80 'definit':84 'differenti':67 'doctrin':90 'electron':30 'entiti':76,83 'es5':10 'frequent':56 'hana':43 'heavili':85 'hibern':88 'influenc':86 'ionic':26 'javascript':9,91 'key':66 'maintain':54 'mapper':18 'mariadb':36 'migrat':60,74 'mongodb':46 'ms':38 'multipl':69 'mysql':34 'nativ':28 'node.js':23 'oracl':41 'orm':5 'pattern':19 'postgresql':35 'progress':65 'react':27 'record':15 'releas':57 'rich':79 'run':21 'sap':42 'server':40 'simultan':71 'sql':39 'sql.js':44 'sqlite':37 'stabl':48 'support':12,68 'typeorm':1,2 'typescript':7 'version':49 'work':32 'x':52,63","created_at":"2026-06-05T17:02:53.756202+00:00","updated_at":"2026-06-05T17:02:53.756202+00:00","problems":[{"fix":"Add the entity to the entities array in the connection or DataSource config: entities: [User] or entities: ['dist/**/*.entity.js'].","cause":"Entity not added to the connection options 'entities' array.","error":"No repository for \"User\" was found. Looks like this entity is not registered in your current connection?"},{"fix":"Configure TypeScript to emit CommonJS modules (module: 'commonjs' in tsconfig.json) or use a bundler.","cause":"Using ES6 import in a CommonJS context without transpilation.","error":"Cannot use import statement outside a module"},{"fix":"Run 'npm install typeorm' and verify the import path is correct (e.g., 'typeorm').","cause":"Package not installed or incorrect import path.","error":"Cannot find module 'typeorm'"},{"fix":"Install the appropriate driver: 'npm install sql.js' or 'npm install better-sqlite3'.","cause":"Missing SQLite driver package; sql.js or better-sqlite3 not installed.","error":"MissingDriverError: Wrong driver: \"sqlite\" given."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/typeorm/typeorm#readme","github":"https://github.com/typeorm/typeorm","docs":null,"changelog":null,"pypi":null,"npm":"typeorm-with-better-sqlite3","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}