0.0.14 • Published 7 years ago

think-websql v0.0.14

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

#Add Package

npm install --save think-websql

#Create File:

custom_definitions/think-websql.d.ts

alt tag

alt tag

alt tag

#Example Typescript:

alt tag

'''

import ThinkWebSql = require("think-websql");

@Injectable()

export class UserData {

db: any;

constructor() {

    this.db = ThinkWebSql.WindowDatabase.openDatabase('thinkdb', '1.0', 'DB ThinkApp', 2 * 1024 * 1024);

    this.db.transaction(function (tx: any){

        tx.executeSql('CREATE TABLE IF NOT EXISTS user (id unique, username, password, hasLoggedIn, defaultPassword);');

        tx.executeSql('INSERT INTO user (id, username, password, hasLoggedIn, defaultPassword) values (1, "thinker", "120130", "false", "102030");');

     });

}

login(user: User) {

    return new Promise((resolve, reject) => {

        this.db.transaction(function (tx: any) {

            tx.executeSql("SELECT password from user WHERE username = '" + user.username.toLowerCase() + "'", [], function (tx: any, results: any) {

                if (results.rows.length > 0) {

                    if (results.rows.item(0).password == user.password)

                        resolve(true);

                }

                resolve(false);

            }, null);

        });

    });

}

}

'''

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago