import { SQLite, SQLiteObject } from '@ionic-native/sqlite'; constructor(private sqlite: SQLite) {} ... this.sqlite.create({ name: 'data.db', location: 'default' }) .then((db: SQLiteObject) => { db.executeSql('CREATE TABLE IF NOT EXISTS people (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)', {}) .then(() => console.log('Executed SQL')) .catch(e => console.log(e)); }) .catch(e => console.log(e));
import { SQLite, SQLiteObject } from '@ionic-native/sqlite'; constructor(private sqlite: SQLite) {} ... this.sqlite.create({ name: 'data.db', location: 'default' }) .then((db: SQLiteObject) => { db.executeSql('SELECT * FROM people', {}) .then((data) => { console.log(data); }) .catch(e => console.log(e)); }) .catch(e => console.log(e));In this example, we create a SQLite database and then execute an SQL query to select all data from the "people" table. The results of the query are then logged to the console. Overall, @ionic-native/sqlite is a useful package library for the Ionic framework that provides native SQLite capabilities for Ionic apps. With TypeScript, developers can easily use this library to create and query SQLite databases within their Ionic apps.