নিম্নলিখিত ফাংশন তথ্য যোগ করার জন্য IndexedDB এর একটি উদাহরণ:
function add() { var request = db.transaction(["employee"], "readwrite") .objectStore("employee") .add({ id: "001", name: "Amit", age: 28, email: "[email protected]" }); request.onsuccess = function(event) { alert("Amit has been added to your database."); }; request.onerror = function(event) { alert("Unable to add data\r\nAmit is already exist in your database! "); } }
উপরে, আমরা ডাটাবেসে নিম্নলিখিত বিবরণ যোগ করেছি:
const employeeData = [ { id: "001", name: "Amit", age: 28, email: "[email protected]" }, ];