Open AgustinJimenez opened 7 years ago
This version not yet implements SQLite. You can to see sample in https://github.com/BradyLiles/ionic-orm-test.
...
createConnection({
driver: {
type: "websql",
database: "test"
},
...
There is a pull request that will provide this. You can use https://github.com/sidneycorreia/ionic-orm.
...
createConnection({
driver: {
type: "ionic-sqlite", // for device
// type: "websql", // for browser
database: "test"
},
...
@sidneycorreia Is your version tested with Ionic 3? Cause it would be a huge improvement for my current Ionic 3 project! Also why did you remove the transaction ? Wouldnt it be better to use
this.databaseConnection.connection.then((db: SQLiteObject) => {
db.transaction((tx) => {
tx.executeSql(query, parameters){
}
}
}
Hi @digaus. My personal project is Ionic 3 and I have not found any issue yet. There is not enough documentation on the transactions for the SQLite plugin and the Ionic Native SQLite plugin. I will work more about transactions.
Meu projeto pessoal é feito com Ionic 3 e não tive problemas. Infelizmente não encontrei documentação suficiente para trabalhar com transactions nem para o SQLite plugin e nem para o Native Ionic SQLite. Vou trabalhar mais em cima das transactions.
@sidneycorreia
I rannpm install https://github.com/sidneycorreia/ionic-orm --save
but get this error when trying to build:
Error: ./src/providers/data-service.ts
Module not found: Error: Can't resolve 'ionic-orm' in 'C:\Users\...\Documents\Visual Studio 2015\Projects\...\src\providers'
resolve 'ionic-orm' in 'C:\Users\...\Documents\Visual Studio 2015\Projects\...\src\providers'
Parsed request is a module
using description file: C:\Users\...\Documents\Visual Studio 2015\Projects\...\package.json (relative path: ./src/providers)
Field 'browser' doesn't contain a valid alias configuration
Any ideas? With the standard ORM it builds fine. How do I add your version of the plugin?
@digaus
Try:
npm install ionic-orm-2
@sidneycorreia Seems to work :) thank you!
@sidneycorreia Do you know how to close a connection? Cause connection.close() only throws an error :/
Please, give me more details about error mensage and your code.
Getting this error: TypeError: this.databaseConnection.connection.close is not a function
Please, let me see the snippet of your code.
There is any guide for use your version? i can't make it work.
Ionic ORM is forked from TypeORM project. This link https://typeorm.github.io/ provide a guide for use. Any samples can be found in https://github.com/typeorm/typeorm/tree/master/sample
sorry, "install it" for my situation, is (npm install ionic-orm-2) and for import is from ionic-orm? or ionic-orm-2?
Uncaught (in promise): cordova_not_available
Hi @agusjim. Import ionic-orm-2.
Example:
import {createConnection} from 'ionic-orm-2'
Example in your entity:
import { Table, PrimaryGeneratedColumn, Column } from 'ionic-orm-2'
@sidneycorreia
I use this.dbConnection = await createConnection(this.connectionParams);
to create the connection and then
this.dbConnection.close().then(
data => console.log("Success"),
onerror => console.log(onerror.toString())
)
This results in the error this.databaseConnection.connection.close is not a function
There is new follow-ups for TypeORM in Ionic3.
I am new on ionic, for this proyect i am using the last ionic version, when i tried to use ionic-orm from BradyLiles/ionic-orm on my provider this happen
Uncaught (in promise): MissingDriverError: Wrong driver sqlite given. Supported drivers are: "mysql", "mysql2", "postgres", "mssql", "oracle", "mariadb", "sqlite". Error at new MissingDriverError ... at ConnectionManager.createDriver ... at ConnectionManager.create ... at ConnectionManager. ... at Generator.next ... at new t ... at __awaiter ... at ConnectionManager.createAndConnectByConnectionOptions ... at ConnectionManager.
i dont know what is going wrong, and i can't post this on stack overflow (my english is bad) this is my provider:
import "reflect-metadata"; import { Injectable } from '@angular/core'; import { createConnection } from 'ionic-orm'; import { Photo } from "./../../entities/Photo"; @Injectable() export class Connection { public create_connection = createConnection; public connection = { driver: { type: "sqlite", host: "localhost", port:"3306", username:"root", password:"admin", database:"test" }, entities: [/"../src/entities/.js"*/Photo], autoSchemaSync:true };
constructor(/create_connection: createConnection/) { console.log( this.connection ); this.query(); }
query() { return this.create_connection(this.connection); } }