Closed gnosis23 closed 4 years ago
这玩意就存储量大点咯?
入门教程
类似于 Table 。
var dbPromise = idb.open('test-db3', 1, function(upgradeDb) { if (!upgradeDb.objectStoreNames.contains('people')) { // define primary key upgradeDb.createObjectStore('people', {keyPath: 'email'}); } if (!upgradeDb.objectStoreNames.contains('notes')) { // define primary key, auto increment upgradeDb.createObjectStore('notes', {autoIncrement: true}); } if (!upgradeDb.objectStoreNames.contains('logs')) { // define primary key id, auto increment upgradeDb.createObjectStore('logs', {keyPath: 'id', autoIncrement: true}); } });
索引......
// objectStore.createIndex('indexName', 'property', options) var dbPromise = idb.open('test-db4', 1, function(upgradeDb) { if (!upgradeDb.objectStoreNames.contains('people')) { var peopleOS = upgradeDb.createObjectStore('people', {keyPath: 'email'}); peopleOS.createIndex('gender', 'gender', {unique: false}); peopleOS.createIndex('ssn', 'ssn', {unique: true}); } if (!upgradeDb.objectStoreNames.contains('notes')) { var notesOS = upgradeDb.createObjectStore('notes', {autoIncrement: true}); notesOS.createIndex('title', 'title', {unique: false}); } if (!upgradeDb.objectStoreNames.contains('logs')) { var logsOS = upgradeDb.createObjectStore('logs', {keyPath: 'id', autoIncrement: true}); } });
这玩意就存储量大点咯?
入门教程
object stores
类似于 Table 。
Indexes
索引......