Having trouble getting SQLite to function properly in Ionic 2

Encountering issues with implementing SQLite plugin in my Angular 2/Ionic 2 project.

Following the Ionic 2 documentation for instantiating SQLite is not yielding expected results.

Received an error message from Sublime:

Supplied parameters do not match any signature of the call target.

This suggests that the constructor requires certain parameters. What are those parameters?

Refer to Ionic 2 SQLite plugin documentation for more information: http://ionicframework.com/docs/v2/native/sqlite/

import { SQLite } from 'ionic-native';

let db = new SQLite();
db.openDatabse({
  name: 'data.db',
  location: 'default' // the location field is required
}).then(() => {
  db.executeSql('create table danceMoves(name VARCHAR(32))', {}).then(() => {

  }, (err) => {
    console.error('Unable to execute sql', err);
  })
}, (err) => {
  console.error('Unable to open database', err);
});

Error message also indicates that Property 'openDatabse' does not exist on type 'SQLite'

Answer №1

Resolved by starting fresh on the project and transferring over the existing app folder, configurations, and re-installing necessary npm packages and Ionic native plugins.

Answer №2

If you're looking to bring in the SQLite object, consider using the following code snippet

import { SQLite, SQLiteObject } from '@ionic-native/sqlite';

Please remember: it's important to install ionic-native/sqlite before proceeding

npm install --save @ionic-native/sqlite

Answer №3

To overcome this issue, I took the following steps:

Firstly, I added and installed a plugin:

ionic cordova plugin add cordova-sqlite-storage

npm install --save @ionic-native/sqlite

Next, I proceeded to create a database:

let db = new SQLite();
            db.openDatabase({
                name: "data.db",
                location: "default"
            }).then(() => {
});

If you encounter an error message like: "openDatabse does not exist on type 'SQLite", simply delete the node_module folder and reinstall it.

Following these steps should resolve the issue effectively.

Answer №4

Instead of Databse, it should be db.openDatabase.

It seems like now it's .create rather than .openDatabase.

When using

.then(() => {db.executeSql ...
, consider adding .then((db: SQLiteObject) and for the next then part :
{}).then(() => {}, (err) => {
insert data within the parentheses

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a Text Typer ReactJS component that functions properly regardless of whether or not it is used within StrictMode is no

My goal is to develop a custom Text Typer component that displays text character by character every 100ms. While it works perfectly fine in production, I encounter issues when testing it in the development environment. Despite trying various solutions, tw ...

What is the process for expanding declared variables in lib.d.ts?

Recently, I came across a Javascript library called History.js History.js acts as a wrapper for the history object in Javascript, allowing for seamless cross-platform functionality. While using it in a standard Javascript environment is straightforward, ...

What is the syntax for declaring a variable with multiple types in Angular/Typescript?

Imagine having a variable declared with the following type: test?: boolean | { [key in TestEnum ]: boolean }; Now, let's assign this test variable within a constant where it can hold either a boolean value or a mapping to an enum. Consider the exampl ...

Vue 3 - Compelled to utilize any data type with computedRef

Recently, I've been diving into Vue/Typescript and encountered a puzzling error. The issue revolves around a class named UploadableFile: export class UploadableFile { file: File; dimensions: Ref; price: ComputedRef<number>; ... constr ...

Execute a function on a specific column within a sqlite query

Imagine having the following table stored in sqlite3. name, currency, price AA, SGD, 1 BB, USD, 2 CC, EUR, 3 There is a need to manipulate the price data based on currency. if currency == "SGD", price = price*2 if c ...

What is causing VSCode's TypeScript checker to overlook these specific imported types?

Encountering a frustrating dilemma within VS Code while working on my Vite/Vue frontend project. It appears that certain types imported from my Node backend are unable to be located. Within my frontend: https://i.stack.imgur.com/NSTRM.png The presence o ...

Struggling with making `http.get` function properly in Angular 2

Attempting to execute a basic GET request using Http in Angular 2, following guidance from this TUTORIAL and other current resources. Upon successfully injecting the http component, the following code was implemented constructor(@Inject(Http) /* remove ...

A solution for resolving the RuntimeException in genuitec's TypeScript Editor for Eclipse Oxygen

After setting up a fresh Eclipse Oxygen and installing the Angular IDE from Genuitec, I encountered an issue on the second day when I opened a project and accessed a *.ts File. The error message displayed was: java.lang.RuntimeException: java.lang.Illegal ...

Facilitate the seamless interchangeability of Angular modules

Consider two feature modules named "sql-connector" and "nosql-connector" that can be brought into the root module: ... import { SqlConnectorModule } from './sql-connector/sql-connector.module'; @NgModule({ ... imports: [ ..., SqlConnectorMod ...

Ways to expand a TypeScript interface and make it complete

I'm striving to achieve the following: interface Partials { readonly start?: number; readonly end?: number; } interface NotPartials extends Partials /* integrate Unpartialing in some way */ { readonly somewhere: number; } In this case, NotPar ...

Error: Unable to instantiate Razorpay as a constructor

Having some trouble integrating Razorpay with Node TypeScript. The issue appears to be related to the const variable razor. Any help or insights would be greatly appreciated. Thank you! import * as Razorpay from 'razorpay'; const razor = new ...

Angular 9: Trouble encountered with utilizing custom error handler for error instances

I'm currently working on implementing a custom error handling system in Angular using the ErrorHandler class. This is what my Globalerror service looks like: export class CustomErrors extends Error { button?: any; errObject: any; constructor() ...

Be patient for the Observable to finish its execution within another Observable

I have a data structure that consists of two classes: Repo and Contributor. export class Repo { id: number; name: string; contributors: Contributor[]; } export class Contributor { id: number; login: string; } Currently, I am using Ob ...

CSS code for a fixed fullscreen menu with scrolling

I have implemented a full-screen menu that covers the entire screen, excluding the header and menu tab bar. You can view it here: https://i.stack.imgur.com/h5cQa.png On smaller screens, the entire menu cannot be displayed at once, as shown here: https://i. ...

Angular CLI - the previous functionality of ng serve proxy has been updated

It's interesting to note that in beta 24 of Angular-CLI, the dist folder was automatically built. However, as of beta 31, it seems that the dist folder is no longer being built when running ng serve. This change has presented a challenge for me becau ...

Using an Angular if statement to validate the current route

I have a modal component that needs to display specific data depending on whether the user came from '/tabs/tab1' or '/tabs/tab2'. The issue is that both sets of data are currently being displayed in the modal component HTML, and the if ...

Angular - Show a table of items from a given list

I recently started using Angular and I'm facing a challenge in displaying multiple tables based on a list of values. Each rule refNo should have its own separate rule conditions table displayed sequentially. Currently, all the tables are showing the s ...

Tips for setting up a personalized preview mode in Sanity Studio using Next.js

I am facing an issue displaying the preview mode because the URL must contain specific parameters such as "category" and "slug" (as shown in the image below). Here is the error URL with undefined parameters Therefore, I am unable to retrieve the paramete ...

Tips for successfully sending an array of numbers using TypeScript and React

Exploring Types in React is new to me and I'm still navigating my way through it. My current challenge involves adding numbers from a form within a child component to an existing array of numbers. To tackle this, I've initialized a useState hoo ...

Strategies for integrating a SQLite Database into your Android app seamlessly

Struggling to find a solution to accessing an SQLite DB across multiple activities within my Android app. I attempted using an application class without success. Can anyone provide an example of how this can be achieved? My app has a tab bar structure, and ...