@pekevski/typeorm
Nativescript + TypeORM
npm i --save @pekevski/typeorm

@pekevski/typeorm

使用方法

  1. 在您的 Nativescript 项目中安装 nativescript sqlite 和 typeorm 依赖。

    npm i typeorm reflect-metadata nativescript-sqlite
    ns plugin add @pekevski/typeorm
  2. 在应用程序的入口点创建数据库连接,例如 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)
    }
    })();
  3. 然后按照 TypeOrm 使用说明进行操作

许可证

Apache 许可证第 2 版