Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mortend committed Aug 2, 2020
1 parent 1cbb140 commit dd952ef
Showing 1 changed file with 52 additions and 32 deletions.
84 changes: 52 additions & 32 deletions README.md
@@ -1,41 +1,51 @@
Fuse SQLite bindings ![Fuse Version](https://fuse-version.herokuapp.com/?repo=https://github.com/bolav/fuse-sqlite)
Fuse SQLite bindings
====================

Library to use [SQLite](https://www.sqlite.org/) in [Fuse](http://www.fusetools.com/).
[![NPM package](https://img.shields.io/npm/v/fuse-sqlite.svg?style=flat-square)](https://www.npmjs.com/package/fuse-sqlite)
[![License: MIT](https://img.shields.io/github/license/fuse-open/fuse-sqlite.svg?style=flat-square)](LICENSE)

Status: beta
Library to use [SQLite](https://www.sqlite.org/) in [Fuse](https://fuseopen.com/).

Currently supports iOS, Android and CIL (Fuse Preview)
Currently supports `ios`, `android` and `dotnet` (Fuse Preview).

Issues, feature request and pull request are welcomed.
Issues, feature requests and pull requests are welcome.

## Installation
## Install

Using [fusepm](https://github.com/bolav/fusepm)
Using [npm](https://www.npmjs.com/)

$ fusepm install https://github.com/bolav/fuse-sqlite
$ npm install fuse-sqlite

(Legacy) Using [fusepm](https://github.com/bolav/fusepm)

$ fusepm install https://github.com/fuse-open/fuse-sqlite

## Usage:

### UX
> Check out the [example app](example/) for a complete example project using TypeScript.
`<SQLite ux:Global="SQLite" />`
### UX

```xml
<SQLite ux:Global="SQLite" />`
```

### JS
### JS or TypeScript

```js
import sqlite from "SQLite";
```
var sqlite = require('SQLite');
var db = sqlite.open("file.sqlite");

```js
const db = sqlite.open("file.sqlite");
db.execute("create table if not exists ids (id integer primary key)");
db.execute("insert into ids values (?)",2);
var r = db.query("select * from ids");
debug_log(JSON.stringify(r));
const r = db.query("select * from ids");
console.log(JSON.stringify(r));
```

It returns an array:
```
```js
[
{"field1":"value1","field2":"value2"},
{"field1":"value1","field2":"value2"}
Expand All @@ -45,34 +55,44 @@ It returns an array:
API
----

### require
### import

```js
import sqlite from "SQLite";
```
var sqlite = require('SQLite');

### require (legacy)

```js
const sqlite = require('SQLite');
```

### sqlite.open

Opens a file that contains a SQLite database

```
var db = sqlite.open(filename);
```js
const db = sqlite.open(filename);
```

### sqlite.openFromBundle

Opens a file that contains a SQLite database, possibly from the bundle

```
var db = sqlite.openFromBundle(filename);
```js
const db = sqlite.openFromBundle(filename);
```

And in the `unoproj`:

```
```json
"Packages": [
"Fuse",
"FuseJS",
"SQLite"
],
"Includes": [
"*.uno",
"*.uxl",
"*.ts",
"*.ux",
"bundle.sqlite:Bundle"
]
Expand All @@ -82,7 +102,7 @@ And in the `unoproj`:

Executes a query. Does not return anything.

```
```js
db.execute(sql_statement);
db.execute(sql_statement, var1, var2, var3);
```
Expand All @@ -91,25 +111,25 @@ db.execute(sql_statement, var1, var2, var3);

Executes a query. Returns an array of hashes with the result.

```
var result = db.query(sql_statement);
var result = db.query(sql_statement, var1, var2, var3);
```js
const result = db.query(sql_statement);
const result = db.query(sql_statement, var1, var2, var3);
```

### db.prepare

Prepares a query. Returns a prepared statement.

```
var statement = db.prepare(sql_statement);
```js
const statement = db.prepare(sql_statement);
statement.execute(var1,var2,var3);
```

### db.close

Closes the database.

```
```js
db.close();
```

Expand Down

0 comments on commit dd952ef

Please sign in to comment.