Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ npx cap sync
```

```
pnpm install --save @capacitor-community/sqlite
pnpm install --save jeep-sqlite
pnpm install --save sql.js
pnpm add @capacitor-community/sqlite
pnpm add jeep-sqlite
pnpm add --save-exact sql.js@1.11.0
npx cap sync
```

Expand Down Expand Up @@ -113,6 +113,12 @@ The plugin follows the guidelines from the `Capacitor Team`,
Meaning that it will not work in IE11 without additional JavaScript transformations, e.g. with [Babel](https://babeljs.io/).
You'll need the usual capacitor/android/react npm script to build and copy the assets folder.

The file `sql-wasm.wasm` must come from `sql.js` 1.11.0. A file from version 1.13.0 or newer does not work. It fails with an error like `function import requires a callable`. The [Web Usage](https://github.com/capacitor-community/sqlite/blob/master/docs/Web-Usage.md) documentation explains why. Install this exact version in your app before you copy the file:

```
npm install --save-exact sql.js@1.11.0
```

#### For Angular framework

- Copy manually the file `sql-wasm.wasm` from `node_modules/sql.js/dist/sql-wasm.wasm` to the `src/assets` folder of YOUR_APP
Expand Down
8 changes: 4 additions & 4 deletions docs/Ionic-React-Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ To install it in your Ionic/React App
npm i --save-dev jeep-sqlite@latest
```

Then follow the setup in [Web Usage](https://github.com/capacitor-community/sqlite/blob/master/docs/Web-Usage.md). It covers `sql.js` and the `sql-wasm.wasm` file.


### React SQLite Hook Declaration for platforms other than Web

Expand Down Expand Up @@ -94,7 +96,7 @@ import { createRoot } from 'react-dom/client';
import App from './App';
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
import reportWebVitals from './reportWebVitals';
import { defineCustomElements as jeepSqlite, applyPolyfills, JSX as LocalJSX } from "jeep-sqlite/loader";
import { defineCustomElements as jeepSqlite, JSX as LocalJSX } from "jeep-sqlite/loader";
import { HTMLAttributes } from 'react';
import { Capacitor } from '@capacitor/core';
import { CapacitorSQLite, SQLiteConnection, SQLiteDBConnection } from '@capacitor-community/sqlite';
Expand All @@ -112,9 +114,7 @@ declare global {
}
}

applyPolyfills().then(() => {
jeepSqlite(window);
});
jeepSqlite(window);
window.addEventListener('DOMContentLoaded', async () => {
console.log('$$$ in index $$$');
const platform = Capacitor.getPlatform();
Expand Down
8 changes: 4 additions & 4 deletions docs/Ionic-Vue-Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@ Now the Singleton SQLite Hook `$sqlite`and Existing Connections Store `$existing
As for the Web platform, the `jeep-sqlite` Stencil component is used and requires the DOM:
the declaration of the SQLite Hook has to be moved to the App.vue

First follow the setup in [Web Usage](https://github.com/capacitor-community/sqlite/blob/master/docs/Web-Usage.md). It covers `jeep-sqlite`, `sql.js` and the `sql-wasm.wasm` file.

So the `main.ts`file
```js
...
import { defineCustomElements as jeepSqlite, applyPolyfills } from "jeep-sqlite/loader";
import { defineCustomElements as jeepSqlite } from "jeep-sqlite/loader";
import { Capacitor } from '@capacitor/core';
import { CapacitorSQLite, SQLiteConnection, SQLiteDBConnection } from '@capacitor-community/sqlite';
import { useState } from '@/composables/state';
import { schemaToImport179 } from '@/utils/utils-import-from-json';

applyPolyfills().then(() => {
jeepSqlite(window);
});
jeepSqlite(window);
window.addEventListener('DOMContentLoaded', async () => {
const platform = Capacitor.getPlatform();
const sqlite: SQLiteConnection = new SQLiteConnection(CapacitorSQLite)
Expand Down
2 changes: 2 additions & 0 deletions docs/TypeORM-Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ In particular in the :
},
```

The `sql-wasm.wasm` file must come from `sql.js` 1.11.0. See [Web Usage](https://github.com/capacitor-community/sqlite/blob/master/docs/Web-Usage.md).

#### 4. Add the following to tsconfig.json

```json
Expand Down
15 changes: 7 additions & 8 deletions docs/Web-Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ When your developement is fully tested, it will be a good idea to minimize the p
```bash
npm i --save @capacitor-community/sqlite@latest
npm i --save jeep-sqlite@latest
npm i --save-exact sql.js@1.11.0
```

`jeep-sqlite` 2.8.0 is built with `sql.js` 1.11.0. The `sql-wasm.wasm` file in your assets folder must come from that same version. `jeep-sqlite` pulls in the newest `sql.js`, so the file in `node_modules` can be too new. A file from version 1.13.0 or newer does not work. It fails with an error like `function import requires a callable`.

`jeep-sqlite` is a Stencil Component which is using `sql.js` for sql in-memory queries and store the database in the Browser on a `localforage` IndexedDB store named `jeepSqliteStore` and inside a table named `databases`.

🚨 The database is stored from in-memory to `localforage` IndexedDB store when one requires
Expand Down Expand Up @@ -725,16 +728,14 @@ that is it.

```js
...
import { defineCustomElements as jeepSqlite, applyPolyfills } from "jeep-sqlite/loader";
import { defineCustomElements as jeepSqlite } from "jeep-sqlite/loader";
import { Capacitor } from '@capacitor/core';
import { CapacitorSQLite, SQLiteConnection, SQLiteDBConnection } from '@capacitor-community/sqlite';
import { useState } from '@/composables/state';


...
applyPolyfills().then(() => {
jeepSqlite(window);
});
jeepSqlite(window);

window.addEventListener('DOMContentLoaded', async () => {
const platform = Capacitor.getPlatform();
Expand Down Expand Up @@ -1130,7 +1131,7 @@ that is it.

```ts
...
import { defineCustomElements as jeepSqlite, applyPolyfills, JSX as LocalJSX } from "jeep-sqlite/loader";
import { defineCustomElements as jeepSqlite, JSX as LocalJSX } from "jeep-sqlite/loader";
import { HTMLAttributes } from 'react';
import { Capacitor } from '@capacitor/core';
import { CapacitorSQLite, SQLiteConnection, SQLiteDBConnection } from '@capacitor-community/sqlite';
Expand All @@ -1148,9 +1149,7 @@ declare global {
}
}

applyPolyfills().then(() => {
jeepSqlite(window);
});
jeepSqlite(window);

window.addEventListener('DOMContentLoaded', async () => {
const platform = Capacitor.getPlatform();
Expand Down
Loading