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