0.0.14 • Published 10 years ago

think-websql v0.0.14

Weekly downloads
1
License
MIT
Repository
-
Last release
10 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

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago