HTML5 IndexedDB 示例
以下函式是用於新增資料的 IndexedDB 示例
function add() {
var request = db.transaction(["employee"], "readwrite")
.objectStore("employee")
.add({ id: "001", name: "Amit", age: 28, email: "demo1@example.com" });
request.onsuccess = function(event) {
alert("Amit has been added to your database.");
};
request.onerror = function(event) {
alert("Unable to add data\r
Amit is already exist in your database! ");
}
}在上面,我們在資料庫中添加了以下詳細資訊
const employeeData = [
{ id: "001", name: "Amit", age: 28, email: "demo1@example.com" },
];
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP