Giter Club home page Giter Club logo

rx-sqlite's Introduction

Rx-SQLite

A wrapper library that adds RxJS 5 API to sqlite3

Installation

npm install rx-sqlite --save

or

yarn add rx-sqlite

Usage

import RxDatabase from "rx-sqlite";
import "rxjs";

let sql = `create table users (name text);
    insert into users values ("john");
    insert into users values ("bob");`;

let db = new RxDatabase(":memory:");

db.exec(sql)
  .switchMap(() => db.each("select rowid, name from users"))
  .subscribe(u => console.log(u));

API

RxDatabase

src/database.js:12-131

Database Wrapper Object that adds RxJS 5 API to sqlite3

constructor

src/database.js:20-22

make new RxDatabase object and open Database.

Parameters

  • filename string ":memory:" or filepath
  • mode Mode (Optional) one or combination value of Mode

prepare

src/database.js:29-40

prepare SQL and bind parameters.

Parameters

Returns RxStatement

run

src/database.js:47-49

Binds parameters and executes the query.

Parameters

Returns Observable<T>

get

src/database.js:56-58

Binds parameters and executes the query and retrieves a row.

Parameters

Returns Observable<T>

all

src/database.js:65-67

Binds parameters and executes the query and retrieves all rows at one time.

Parameters

Returns Observable<Array<T>>

each

src/database.js:74-91

Binds parameters and executes the query and retrieves all rows.

Parameters

Returns Observable<T>

exec

src/database.js:96-98

executes the multiple query.

Parameters

Returns Observable<void>

events

src/database.js:103-111

make new specified event stream.

Parameters

Returns Observable<Event>

busyTimeout

src/database.js:117-121

Set A Busy Timeout

Parameters

  • timeout number milliseconds of sleeping time

close

src/database.js:128-130

close the Database.

you should call this method when you work done

verbose

src/index.js:9-11

see node-sqlite3/Debugging

OPEN_READONLY

src/index.js:16-16

The database is opened in read-only mode.

OPEN_READWRITE

src/index.js:21-21

The database is opened for reading and writing if possible.

OPEN_CREATE

src/index.js:26-26

The database is opened for reading and writing, and is created if it does not already exist.

Mode

src/index.js:31-31

supported database opening flags

Type: (OPEN_READONLY | OPEN_READWRITE | OPEN_CREATE)

EventName

src/index.js:36-36

supported event names

Type: ("error" | "open" | "close" | "profile" | "trace")

RxStatement

src/statement.js:10-104

Statement Wrapper Object that adds RxJS 5 API to sqlite3

errors

src/statement.js:20-29

make new error event stream.

Returns Observable<{error: Error}>

run

src/statement.js:35-37

Binds parameters and executes the statement.

Parameters

Returns Observable<T>

get

src/statement.js:43-45

Binds parameters and executes the statement and retrieves a row.

Parameters

Returns Observable<T>

all

src/statement.js:51-53

Binds parameters and executes the statement and retrieves all rows at one time.

Parameters

Returns Observable<Array<T>>

each

src/statement.js:59-78

Binds parameters and executes the statement and retrieves all rows.

Parameters

Returns Observable<T>

bind

src/statement.js:84-88

Binds parameters to the prepared statement

Parameters

Returns Observable<RxStatement>

reset

src/statement.js:93-97

Returns Observable<RxStatement>

Development

Setup

git clone https://github.com/taichi/rx-sqlite
yarn install
yarn setup

Build

yarn build

License

Copyright 2017 taichi

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

rx-sqlite's People

Contributors

taichi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.