2015-06-17 41 views
0

我不知道我做錯了什麼在這裏,這是地獄調試它最喜歡的科爾多瓦插件...ngCordova - 無法SQLite的記錄

我只是嘗試存儲弦數.. (我只需要它一個控制器)

var db = $cordovaSQLite.openDB({ name: "videos" }); 
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS videos (id integer primary key, video mediumtext)"); 

// getting some data from the server, nothing special 

query = "INSERT INTO videos (id, video) VALUES (?)"; 
$cordovaSQLite.execute(db, query, [response.Data.media]).then(function(result) { 
    console.log(result); 
    var message = "INSERT ID -> " + result.insertId; 
    console.log(message); 
}, function (err) { 
    console.error(err); 
    //alert(err); 
}); 

我得到的插入ID,所以它必須被保存的東西......但是,當我嘗試使用功能

var query = "SELECT * FROM videos where id = 1"; 
$cordovaSQLite.execute(db, query).then(function(result) { 
    console.log(result); 
}); 

我加載它一無所獲。

enter image description here

天體物理學家就稱它爲空的空間,但我們的開發人員,我們需要的數據進行處理!爲什麼行中沒有任何東西? (無論我選擇id還是所有內容,它只是向我展示這種沒有數據的空對象)。

非常感謝您的幫助!

回答

4

您應該能夠遍歷這樣的結果:

var output = []; 
for (var i = 0; i < result.rows.length; i++) { 
    output.push(result.rows.item(i)); 
} 
console.log(JSON.stringify(output)); 

然後,當你看它輸出將包含一個數據結果的數組。

+0

謝謝,它的工作。 :) – Shay