當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ionic-native.SQLite類代碼示例

本文整理匯總了TypeScript中ionic-native.SQLite的典型用法代碼示例。如果您正苦於以下問題:TypeScript SQLite類的具體用法?TypeScript SQLite怎麽用?TypeScript SQLite使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SQLite類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

 constructor(private navController: NavController, private platform: Platform) {
   this.database = new SQLite();
   this.database.openDatabase({name: "data.db", location: "default"}).then(() => {
     //this.refresh();
   }, (error) => {
     console.log("ERROR: ", error);
   });
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:8,代碼來源:home.ts

示例2: tests

        }).then(() => {
          this.db.executeSql('CREATE TABLE IF NOT EXISTS tests (id INTEGER PRIMARY KEY AUTOINCREMENT, name Text, user_id Text, date TIMESTAMP)', {}).then((data) =>{
            console.log("TESTS TABLE CREATED", JSON.stringify(data.res));
          }, (error) => {
            console.log("Error creating tests table", JSON.stringify(error.err));
          });

          this.db.executeSql('CREATE TABLE IF NOT EXISTS test_sections (id INTEGER PRIMARY KEY AUTOINCREMENT, section INTEGER, question TEXT, score TEXT, question_id INTEGER, test_id INTEGER, CONSTRAINT composite_id UNIQUE (section, question_id, test_id))', {}).then((data) =>{
            console.log("TEST SECTIONS TABLE CREATED", JSON.stringify(data.res));
          }, (error) => {
            console.log("Error creating tests table", JSON.stringify(error.err));
          });

          }, (err) => {
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:14,代碼來源:sqlite.ts

示例3: add

 public add() {
   this.database.executeSql("INSERT INTO user (firstname, lastname) VALUES (?, ?)", ['Alejandro', 'Romero']).then((data) => {
     console.log("INSERTED: " + JSON.stringify(data));
   }, (error) => {
     console.log("ERROR: " + JSON.stringify(error));
   });
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:7,代碼來源:home.ts

示例4: createTable

 createTable(){
   let sql = 'CREATE TABLE IF NOT EXISTS product(' +
       'id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
       'type TEXT, ' +
       'quantity INTEGER, ' +
       'price TEXT, ' +
       'name TEXT)';
   return this.db.executeSql(sql, []);
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:9,代碼來源:service.ts

示例5: getAll

 getAll(){
   let query = 'SELECT * FROM product';
   return this.db.executeSql(query, [])
     .then(response => {
       let products = [];
       for (let index = 0; index < response.rows.length; index++) {
         products.push(response.rows.item(index));
       }
       return Promise.resolve(products);
     })
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:11,代碼來源:service.ts

示例6: refresh

 public refresh() {
   this.database.executeSql("SELECT * FROM user", {}).then((data) => {
     this.user = [];
     if(data.rows.length > 0) {
       for(var i = 0; i < data.rows.length; i++) {
         this.user.push({firstname: data.rows.item(i).firstname, lastname: data.rows.item(i).lastname});
       }
     }
   }, (error) => {
     console.log("ERROR: " + JSON.stringify(error));
   });
 }
開發者ID:alejo8591,項目名稱:charla-git,代碼行數:12,代碼來源:home.ts

示例7: deleteTestByUser

 public deleteTestByUser(user_id: number) {
    let sql = 'DELETE FROM tests WHERE user_id = ?';
    return this.db.executeSql(sql, [user_id]);
 }
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:4,代碼來源:sqlite.ts

示例8: update

 // Update an existing note with a given ID
 public update(test: Test) {
     let sql = 'UPDATE test_sections SET score = ? WHERE section = ? AND question_id = ? AND test_id = ?';
     return this.db.executeSql(sql, [test.score, test.section, test.question_id, test.test_id]);
 }
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:5,代碼來源:sqlite.ts

示例9: deleteAnswers

 public deleteAnswers(id: number){
     let sql = 'DELETE FROM test_sections WHERE test_id = ?';
     return this.db.executeSql(sql, [id]);
 }
開發者ID:alexandrastoica,項目名稱:ionic2-dementia-test-app,代碼行數:4,代碼來源:sqlite.ts


注:本文中的ionic-native.SQLite類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。