-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue type:
[x] question
[ ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[x] sqljs
[ ] websql
TypeORM version:
[ ] latest
[ ] @next
[x] 0.1.11 (or put your version here)
Steps to reproduce or a small repository showing the problem:
Inside an ionic application I create the connection and populate it with data. My models contains relations from Product going down to other models, this mean in Product model I set up relation with cascade insert/updates so I only need to hydrate products and save instead saving all models separately.
Connection setup:
if (isBrowser(this.platform)) {
dbOptions = {
type: 'sqljs',
autoSave: true,
location: 'products',
} as SqljsConnectionOptions;
}
return createConnection(Object.assign(dbOptions, {
entities: this.getModelsToLoad(),
synchronize: true,
logging: true,
}));After I populate database everything works fine, and then after I reload page, i can see queries ran in console, because synchronize: true, i assume. Last query is:
executing query: CREATE TABLE "temporary_product" ("identifier" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "id" varchar NOT NULL, ....)
executing query: INSERT INTO "temporary_product"("identifier", "id", ....) SELECT "identifier", "id", ... FROM "product"
executing query: DROP TABLE "product"
executing query: ROLLBACK
than I receive the error.
Could you guys help me on how to overcome this. My expected outcome would be that I can use same data after a page reload, since that's happens a lot when developing in browser an ionic app. Foreign keys enabled are not allowing me to re-initialize database again from existent data.
Thanks in advance,
David