TypeOrm
  • Getting Started
  • About
  • Connection
    • Working with Connection
    • Using ormconfig.json
    • Connection Options
    • Multiple connections
    • Connection APIs
  • Entity
    • What is Entity?
    • Embedded Entities
    • Entity Inheritance
    • Tree Entities
    • View Entities
    • Separating Entity Definition
  • Relations
    • What are Relations?
    • One-to-One
    • Many-to-one and One-to-Many
    • Many-to-Many
    • Eager and Lazy Relations
    • Relations FAQ
  • Entity Manager and Repository
    • What is EntityManager
    • Working with Repository
    • Find Options
    • Custom Repositories
    • Entity Manager API
    • Repository API
  • Query Builder
    • Select using Query Builder
    • Insert using Query Builder
    • Update using Query Builder
    • Delete using Query Builder
    • Working with Relations
    • Caching Results
  • Advanced Topics
    • Using CLI
    • Logging
    • Listeners and Subscribers
    • Indices
    • Transactions
    • Migrations
  • Guides
    • Active Record vs Data Mapper
    • Working with MongoDB
    • Using Validation
    • Example with Express
    • Usage with JavaScript
    • Migration from Sequelize
  • Help
    • FAQ
    • Supported Platforms
    • Decorators reference
    • Roadmap
    • Changelog
Powered by GitBook
On this page
  • NodeJS
  • Browser
  • Cordova / PhoneGap / Ionic apps
  • React Native
  • Expo
  • NativeScript

Was this helpful?

  1. Help

Supported Platforms

PreviousFAQNextDecorators reference

Last updated 4 years ago

Was this helpful?

  • NodeJS

  • Browser

  • Cordova / PhoneGap / Ionic apps

  • React Native

  • Expo

  • NativeScript

NodeJS

TypeORM was tested on Node.js version 4 and above.

Browser

You can use in the browser.

Webpack configuration

In the browser folder the package also includes a version compiled as a ES2015 module. If you want to use a different loader this is the point to start. Prior to TypeORM 0.1.7, the package is setup in a way that loaders like webpack will automatically use the browser folder. With 0.1.7 this was dropped to support Webpack usage in Node.js projects. This means, that the NormalModuleReplacementPlugin has to be used to insure that the correct version is loaded for browser projects. The configuration in your webpack config file, for this plugin looks like this:

plugins: [
    ..., // any existing plugins that you already have
    new webpack.NormalModuleReplacementPlugin(/typeorm$/, function (result) {
        result.request = result.request.replace(/typeorm/, "typeorm/browser");
    }),
    new webpack.ProvidePlugin({
      'window.SQL': 'sql.js/dist/sql-wasm.js'
    })
]

Example of configuration

createConnection({
    type: "sqljs",
    entities: [
        Photo
    ],
    synchronize: true
});

Don't forget to include reflect-metadata

In your main html page, you need to include reflect-metadata:

<script src="./node_modules/reflect-metadata/Reflect.js"></script>

Cordova / PhoneGap / Ionic apps

React Native

Expo

NativeScript

  1. tns install webpack (read below why webpack is required)

  2. tns plugin add nativescript-sqlite

  3. Create Database connection in your app's entry point

     import driver from 'nativescript-sqlite'
    
     const connection = await createConnection({
         database: 'test.db',
         type: 'nativescript',
         driver,
         entities: [
             Todo //... whatever entities you have
         ],
         logging: true
     })

Note: This works only with NativeScript 4.x and above

When using with NativeScript, using webpack is compulsory. The typeorm/browser package is raw ES7 code with import/export which will NOT run as it is. It has to be bundled. Please use the tns run --bundle method

and make sure exists in your public path.

TypeORM is able to run on Cordova, PhoneGap, Ionic apps using the plugin You have the option to choose between module loaders just like in browser package. For an example how to use TypeORM in Cordova see and for Ionic see . Important: For use with Ionic, a custom webpack config file is needed! Please checkout the example to see the needed changes.

TypeORM is able to run on React Native apps using the plugin. For an example see .

TypeORM is able to run on Expo apps using the . For an example how to use TypeORM in Expo see .

Checkout example !

sql.js
sql-wasm.wasm file
cordova-sqlite-storage
typeorm/cordova-example
typeorm/ionic-example
react-native-sqlite-storage
typeorm/react-native-example
Expo SQLite API
typeorm/expo-example
here