npm i --save @chris7519/nativescript-typeorm-plugin
- 版本:1.0.7
- GitHub: https://github.com/chrissm79/nativescript-typeorm-plugin-seed
- NPM: https://npmjs.net.cn/package/%40chris7519%2Fnativescript-typeorm-plugin
- 下载量
- 昨日: 0
- 上周: 0
- 上个月: 0
@chris7519/typeorm
使用说明
-
在您的 Nativescript 项目中安装 nativescript sqlite 和 typeorm 的依赖项。
npm i typeorm reflect-metadata nativescript-sqlite
ns plugin add @chris7519/typeorm -
在应用程序的入口点创建数据库连接,例如
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)
}
})(); -
然后按照如何使用 TypeOrm 的说明进行操作
许可协议
Apache 许可证 2.0 版本