-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
41 lines (31 loc) · 1.11 KB
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// open adtabase
// create ObjectStore
// Make Datbase
let db;
let openRequest=indexedDB.open("myDataBase");
//Db has these three Event
// HMRA DB OPEN OH IN CASE OF SUCCES VLA CHLE GA
//IN CASE OF FAILURE ,FAILURE VLA CHLE GA
//SECOND ONE
openRequest.addEventListener("success",e=>{
console.log("DB Success");
db=openRequest.result;
});
openRequest.addEventListener("error",e=>{
console.log("DB error");
});
//FIRST ONE THIS CALL
//UPGRADED BASICALLY FOR VERSION
//I WE LOWER VERSION THEN JO CURRENT VERSION HAI VHI FOLOW KRE GA THEN
// INTIALLY DB YHI CREATE HOGA NEW
// intially isse jagah db create hoga
openRequest.addEventListener("upgradeneeded",e=>{
console.log("DB upgraded and also for initial DB creation");
db=openRequest.result;
//SECOND CREATE OBJECT STore
// keypath me hm id store kr reh hai
// keypath we use here to uniquely identify each and every data.
//keypath ke andar hm term use kre ge id for unikely identify the term
db.createObjectStore("video",{keyPath:"id"}); //vedio store
db.createObjectStore("image",{keyPath:"id"}); //image stroe
});