Hi, in my ionic 6 project upgrade cordova 10 to 11, upgrade typeorm 0.2.34 to 0.2.35.
I understand that between these versions the transactions no longer exist.
When creating the connection to the db it causes the following error:
TypeORMError: Transactions are not supported by the Cordova driver"
“@ionic/core”: “6.1.8”,
“cordova”: “11.0.0”,
“cordova-android”: “^11.0.0”,
“cordova-sqlite-storage”: “6.0.0”,
“typeorm”: “0.2.35”,
Code block where I create the connection:
private async createConnection( ): Promise {
return await new Promise(async resolve => {
await this.platform.ready().then(async () => {
// if (this.platform.is('cordova')) {
const isMobile = await this.revisaOrigenDispositivo();
if(isMobile) {
console.log(this.TAG,'DbService -> mobile! ');
this._dbOptions = {
type: 'cordova',
location: 'default',
database: environment.nombredb,
name: 'default',
logging: ['error', 'query', 'schema'],
};
} else {
console.log(this.TAG,'DbService -> sqljs ');
this._dbOptions = {
type: 'sqljs',
location: environment.nombredb,
autoSave: true,
name: 'default'
};
}
Object.assign(this._dbOptions, {
logging:['warn', 'error','info','log','warning'],
keepConnectionAlive: true,
androidDatabaseProvider: 'system',
entities: [
ttDistribuidora, ttArticulo, ttFiltro, ttFiltroRelacionado, ttPromos, ttDetallePromo,
ttImagenes, ttMovilTienda, ttTiendaEmpresaCliente, ttAgrupacion,
ttLineaPedido, ttCabecera, ttIbr, ttIbrEmpresa, ttIbrProvincia,
ttPromosCliente, ttTipoDoc, ttNotificaciones, ttVideoUrl, ttLog, ttMovilTiendaTemporal,ttCombo
]
});
});
// console.log(this.TAG, 'createConnection->dboption:', JSON.stringify(this._dbOptions));
return await createConnection(this._dbOptions).then(async connection => {
console.log(this.TAG, 'createConnection->create 1');
resolve(connection);
}).catch( async error => {
console.log(this.TAG, 'error:',error);
**// HERE ERROR: "DbService error: TypeORMError: Transactions are not supported by the Cordova driver"**
if (error.name === 'AlreadyHasActiveConnectionError') {
const existentConn = getConnectionManager().get();
console.log(this.TAG, 'return existenConn');
resolve(existentConn);
} else {
resolve(null);
}
});