npm i --save @chris7519/nativescript-typeorm-plugin
- Version: 1.0.7
- GitHub: https://github.com/chrissm79/nativescript-typeorm-plugin-seed
- NPM: https://www.npmjs.com/package/%40chris7519%2Fnativescript-typeorm-plugin
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
@chris7519/typeorm
Usage
-
Install the dependencies for nativescript sqlite and typeorm in your Nativescript project.
npm i typeorm reflect-metadata nativescript-sqlite
ns plugin add @chris7519/typeorm -
Create a database connection in your applications entry point eg.
main.ts
let driver = require('nativescript-sqlite');
// use an iife to run it before angular starts
(async () => {
console.log('START APP')
try {
const connection = await createConnection({
database: 'test.db',
type: 'nativescript',
driver,
entities: [
User,
// ... more models here
],
logging: true
})
// Dangerously drops all tables on app start if true
// connection.synchronize(true);
console.log("Connection Created")
} catch (err) {
console.error(err)
}
})(); -
Then follow the instructions on how to use TypeOrm
License
Apache License Version 2.0