0
我一直在使用nativescript-sqlite插件一段時間。我從我的表格中選擇數據的工作正常。我想通過我的表格列名訪問這些數據,這就是挑戰開始的地方。在SQLite中按列名讀取查詢結果Nativescript
viewModel.selectAllRecords = function() {
new sqlite("etudiz.db", function (err, db) {
db.all("SELECT post_title,post_cat FROM posts ORDER BY id", [], function (tableErr, rs) {
var ObjLength = rs.length;
var i = 0;
for(i >= 0; i<ObjLength; i++) {
console.log(rs[i]['post_title']) //This is undefined
console.log(rs[i][0])//This is working well
}
});
});
};
我更喜歡按列名而不是0,1,2 ....等讀取數據。有沒有解決辦法,或者SQLite是如何設計的?