Registry / database / ionic-orm

ionic-orm

JSON →
library0.0.5jsnpmunverified

Ionic-ORM (v0.0.5) is a fork of TypeORM for Ionic 2+ Cordova apps, using WebSQL or SQLite. It provides a data-mapper pattern with decorators (@Table, @Column) for relational database mapping in TypeScript/JavaScript. Release cadence is low; last update was in 2017. Key differentiator: tailored for Ionic mobile apps with Cordova SQLite storage. However, it is largely unmaintained and inferior to updated TypeORM or other modern alternatives.

npm install ionic-orm
INSTALL
IMPORT
SIG · IONIC-ORM
I
ionic-orm
databasejavascriptv0.0.5
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.

Table
import { Table } from 'ionic-orm'
const { Table } = require('ionic-orm')
ESM import; CJS require() works but is not recommended for modern code.
Column
import { Column } from 'ionic-orm'
import Column from 'ionic-orm'
Named export, not default.
CreateConnection
import { createConnection } from 'ionic-orm'
import { CreateConnection } from 'ionic-orm'
Function is camelCase 'createConnection', not PascalCase.

Shows setup with reflect-metadata, define an entity with decorators, create connection, save a record, and handle errors.

import 'reflect-metadata'; import { createConnection, Table, Column, PrimaryColumn } from 'ionic-orm'; @Table() export class Photo { @PrimaryColumn() id: number; @Column() name: string; @Column() description: string; @Column() fileName: string; @Column() views: number; @Column() isPublished: boolean; } createConnection({ type: 'cordova', database: 'test.db', entities: [Photo], synchronize: true, }).then(async connection => { const photo = new Photo(); photo.name = 'Me and Bears'; photo.description = 'I am near polar bears'; photo.fileName = 'photo-with-bears.jpg'; photo.views = 5; photo.isPublished = true; const photoRepository = connection.getRepository(Photo); await photoRepository.save(photo); console.log('Photo has been saved'); }).catch(error => console.log(error));
Debug
Known issues
breakingIonic-ORM has not been updated since 2017; it relies on outdated TypeORM core.
fix
Consider using TypeORM directly or a maintained alternative.
affects: >=0.0.1
deprecatedWebSQL is deprecated and will be removed from Chrome; only works in hybrid apps.
fix
Use SQLite plugin with native storage instead of WebSQL.
affects: >=0.0.1
gotchaThe package has no types; you must install @types/reflect-metadata for TS.
fix
npm install --save-dev @types/reflect-metadata
affects: >=0.0.1
gotchaMissing reflect-metadata polyfill causes 'reflect-metadata shim is required' error.
fix
Add import 'reflect-metadata' as the first line of your app entry.
affects: >=0.0.1
breakingcreateConnection does not accept sqlite type; uses 'cordova' or 'websql'.
fix
Specify type: 'cordova' for SQLite plugin or type: 'websql' for WebSQL.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'ionic-orm'
Package not installed or missing from node_modules.
fix
Run npm install ionic-orm --save
Reflect-metadata shim is required when using class decorators
reflect-metadata not imported at app entry point.
fix
Add import 'reflect-metadata' to the top of your main file.
Property 'save' does not exist on type 'Repository<Photo>'
TypeScript strict mode or wrong version of TypeORM types used.
fix
Ensure you have the correct @types/ionic-orm or use 'any' cast: (repository as any).save(photo)
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies
reflect-metadatarequiredRequired for decorator support at runtime.
cordova-sqlite-storageoptionalSQLite driver for Ionic/Cordova apps.
Agent activity
6 hits · last 30 days
node
6
Resources
ionic-orm — npm install ionic-orm · libregistry