@mohamedwahshey wrote:
I’m trying to post data into entities using typeorm, and getting this error:
ERROR Error: Uncaught (in promise): AlreadyHasActiveConnectionError: Cannot create a new connection named “default”, because connection with such name already exist and it now has an active connection session.
ErrorWhat i’m doing is, i’m connecting to the db in app.component.ts and it works perfectly, then in another page ts file i’m trying to post a data from a form to the entity and this is where my issue is, it keeps telling me that it has already active connection, so what am i supposed to do to post data to the db with typeorm?
TS:
import { createConnection } from "ionic-orm"; onAddEquipment() { let options: ConnectionOptions = { autoSchemaSync: true, driver: { type: "websql", database: "bexel" }, entities: [ Equipments ] } createConnection(options).then(async connection => { let equipment = new Equipments(); equipment = this.equipment; await connection.entityManager.persist(equipment); console.log("equipment has been saved"); }); }
I followed this documentation.
Someone kindly help and show me how can we write the right statement.
Note that it’s working without typeorm with native sqlite queries, so no problem with the form it’s just i don’t know how to write the statement right.
Posts: 1
Participants: 1