How do I use the mysql node module from ionic 2?

0

I need to connect to a database using the mysql module of node_modules, using the ionic 2 framework, in previous projects where I worked with express only easily, but with ionic 2 I do not know how to integrate these, what I have achieved find on the internet do it this way, but the keyword require does not recognize it and therefore can not find the module.

modulos.import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
var mySQLLibreria = require('mysql');

/*
  Generated class for the ServicioMySQL provider.

  See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  for more info on providers and Angular 2 DI.
*/
@Injectable()
export class ServicioMySQL {
    mySQL; 


  constructor(public http: Http) {
    console.log('Hello ServicioMySQL Provider');
    this.mySQL= mySQLLibreria;
  }

}
    
asked by Daniel Enrique Rodriguez Caste 25.05.2017 в 18:52
source

1 answer

0

I think you're confusing concepts, if it's not like that, I do not understand what you want to do.

I'll explain a bit as I see it:

Ionic is used to create mobile apps that may or may not have their own BD on the phone, for this use SQLite Databases and you can access them with the sqlite plugin, more info here

If you want to connect to a MySQL database that runs on an internet server, you will have to do it through HTTP calls to an API.

    
answered by 25.05.2017 в 19:31