Registry / database / sqlite-websql-orm

sqlite-websql-orm

JSON →
library1.2.1jsnpmunverified

An ORM for SQLite and WebSQL databases, designed for Angular 2+ and Ionic 2+ applications. Version 1.2.1 is the current stable release, with support for Angular 6 and Node >=8.11. The package has undergone major breaking changes from version 0.2.2 to 1.0.0+, replacing the module name from OrmModule to SqliteWebsqlOrmModule, introducing adapters (ADAPTERS.auto, ADAPTERS.sqlite, ADAPTERS.websql) instead of useFakeData, and simplifying schema generation. It ships TypeScript types and has peer dependencies on @angular/common, @angular/core, @ionic-native/core, @ionic-native/sqlite, rxjs, and rxjs-compat. Key differentiator: works across both WebSQL (browser) and SQLite (mobile) with a single API.

npm install sqlite-websql-orm
INSTALL
IMPORT
SIG · SQLITE-WEBSQL-ORM
S
sqlite-websql-orm
databasejavascriptv1.2.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.

SqliteWebsqlOrmModule
import { SqliteWebsqlOrmModule } from 'sqlite-websql-orm'
import { OrmModule } from 'sqlite-websql-orm'
Module renamed from OrmModule to SqliteWebsqlOrmModule in v1.0.0+
ADAPTERS
import { ADAPTERS } from 'sqlite-websql-orm'
import { USE_FAKE_DATA } from 'sqlite-websql-orm'
useFakeData replaced by ADAPTERS in v1.0.0+
SchemaFactory
import { SchemaFactory } from 'sqlite-websql-orm'
Exists in both versions but usage differs: generateSchema() no longer takes parameters in v1.0.0+
Repository
import { Repository } from 'sqlite-websql-orm'
import { RepositoryStore } from 'sqlite-websql-orm'
Repository decorator from 'sqlite-websql-orm'; RepositoryStore was removed in v1.0.0+

Shows how to initialize the ORM module, configure the adapter, and generate the schema in an Angular/Ionic app.

import { NgModule } from '@angular/core'; import { SqliteWebsqlOrmModule, SchemaFactory, Manager, ADAPTERS } from 'sqlite-websql-orm'; import { Platform } from '@ionic/angular'; @NgModule({ imports: [ SqliteWebsqlOrmModule.init({ name: 'my_custom_database.db', location: 'default', options: { adapter: ADAPTERS.auto, webname: 'my_custom_database', description: 'SQLite/WebSQL database for browser', version: '1.0', maxsize: 2 * 1024 * 1024 } }) ] }) export class AppModule { constructor( private schema: SchemaFactory, private platform: Platform ) { this.platform.ready().then(() => { this.schema.generateSchema() .then(() => console.log('Database created')) .catch(err => console.error(err)); }); } }
Debug
Known issues
breakingModule name changed from OrmModule to SqliteWebsqlOrmModule in v1.0.0+.
fix
Replace OrmModule with SqliteWebsqlOrmModule in imports and @NgModule.
affects: >=1.0.0
breakinguseFakeData option replaced by adapter. Use ADAPTERS enum.
fix
Replace useFakeDatabase: true with adapter: ADAPTERS.auto.
affects: >=1.0.0
breakinggenerateSchema() no longer accepts parameters. Schema sources are auto-detected.
fix
Remove arguments from generateSchema() call; do not import RepositoryStore.
affects: >=1.0.0
breakingRepositoryStore class removed. Use @Repository decorator directly.
fix
Remove imports of RepositoryStore; use @Repository decorator on services.
affects: >=1.0.0
gotchaPeer dependencies may need manual installation. Angular 6+ requires rxjs-compat.
fix
Run npm install @angular/common @angular/core @ionic-native/core @ionic-native/sqlite rxjs rxjs-compat --save
affects: >=1.0.0
deprecatedWebSQL is deprecated in some browsers; consider using SQLite adapter for production.
fix
Set adapter to ADAPTERS.sqlite if WebSQL not desired.
affects: >=0.0.0
Errors
Common errors & fixes
Module 'OrmModule' is not exported from 'sqlite-websql-orm'
Module renamed to SqliteWebsqlOrmModule in v1.0.0+
fix
Use import { SqliteWebsqlOrmModule } from 'sqlite-websql-orm'
Property 'useFakeDatabase' does not exist on type 'InitConfig'
useFakeData replaced by adapter in v1.0.0+
fix
Replace with adapter: ADAPTERS.auto (or ADAPTERS.sqlite / ADAPTERS.websql)
Expected 0 arguments, but got 1 in 'generateSchema'
generateSchema() no longer accepts schema sources in v1.0.0+
fix
Call this.schema.generateSchema() without arguments
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
@angular/commonrequiredRequired for Angular module and dependency injection
@angular/corerequiredRequired for Angular decorators and lifecycle
@ionic-native/corerequiredRequired for Ionic native plugin wrappers
@ionic-native/sqliterequiredRequired for SQLite database access on mobile
rxjsrequiredRequired for reactive observables
rxjs-compatrequiredRequired for backwards compatibility with RxJS 5
Agent activity
54 hits · last 30 days
node
46
Meta
2
OpenAI (training)
1
Resources