From 9d1637f1839e42ec8a7ef6ba46e3ae1323a80b77 Mon Sep 17 00:00:00 2001 From: Daniel Lang Date: Tue, 21 Nov 2017 22:21:21 +0100 Subject: [PATCH 1/2] es6 has problems with circular dependencies, this are the needed changes for es6 --- package.json | 3 --- src/entities/author.ts | 6 +----- src/entities/post.ts | 2 +- src/pages/home/home.ts | 6 ++++-- tsconfig.json | 2 +- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 5f5682e..b3c87a0 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,6 @@ "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve" }, - "config": { - "ionic_webpack": "./config/webpack.config.js" - }, "dependencies": { "@angular/common": "4.4.3", "@angular/compiler": "4.4.3", diff --git a/src/entities/author.ts b/src/entities/author.ts index 3c7be27..23be3a8 100644 --- a/src/entities/author.ts +++ b/src/entities/author.ts @@ -1,5 +1,4 @@ -import {Entity, Column, PrimaryGeneratedColumn, OneToMany} from "typeorm"; -import {Post} from "./post"; +import {Entity, Column, PrimaryGeneratedColumn} from "typeorm"; @Entity('author') export class Author { @@ -12,7 +11,4 @@ export class Author { @Column({nullable: true}) birthdate: string; - - @OneToMany(type => Post, post => post.author) - posts: Post[]; } diff --git a/src/entities/post.ts b/src/entities/post.ts index fa76259..7e7874c 100644 --- a/src/entities/post.ts +++ b/src/entities/post.ts @@ -20,7 +20,7 @@ export class Post { @JoinTable() categories: Category[]; - @ManyToOne(type => Author, author => author.posts, { + @ManyToOne(type => Author, { cascadeInsert: true }) author: Author; diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index 28aea76..c773bf8 100644 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -22,9 +22,11 @@ export class HomePage { async connect() { await createConnection({ - type: 'cordova', + type: 'websql', database: 'test', - location: 'default', + size: 1024 * 1024, + version: '1.0', + description: '', logging: ['error', 'query', 'schema'], synchronize: true, entities: [ diff --git a/tsconfig.json b/tsconfig.json index e70db4d..af4d056 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "module": "es2015", "moduleResolution": "node", "sourceMap": true, - "target": "es5", + "target": "es6", "typeRoots": [ "node_modules/@types" ] From a82da9c85fd7d133538bfe07881d871f224bae4c Mon Sep 17 00:00:00 2001 From: Daniel Lang Date: Tue, 21 Nov 2017 22:25:19 +0100 Subject: [PATCH 2/2] changed connection back to cordova driver --- package.json | 2 +- src/pages/home/home.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b3c87a0..473c808 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "ionicons": "3.0.0", "rxjs": "5.4.3", "sw-toolbox": "3.6.0", - "typeorm": "0.1.0", + "typeorm": "0.1.5", "zone.js": "0.8.17" }, "devDependencies": { diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index c773bf8..28aea76 100644 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -22,11 +22,9 @@ export class HomePage { async connect() { await createConnection({ - type: 'websql', + type: 'cordova', database: 'test', - size: 1024 * 1024, - version: '1.0', - description: '', + location: 'default', logging: ['error', 'query', 'schema'], synchronize: true, entities: [