Today we are going to look at IndexedDB and Google Drive API
But first, download this repo:
https://github.com/shovon/iat381-lab9.git
var dbName = 'todo_list_store';
sklad.open(dbName, {
version: 1,
migration: {
'1': function (database) {
var objStore = database.createObjectStore('todos', {autoIncrement: true});
objStore.createIndex('description_search', 'description', {unique: true});
}
}
}, function (err, conn) {
if (err) { throw err; }
$(function () {
var $description = $('#description');
var $add = $('#add');
var $list = $('#list')
function updateRows(conn) {
conn
.get({
todos: {description: sklad.DESC, index: 'description_search'}
}, function (err, data) {
if (err) { return console.error(err); }
// TODO: do stuff here.
});
}
updateRows(conn);
$add.click(function () {
if (!$description.val().trim()) {
return;
}
conn.insert({
todos: [
{ description: $description.val() }
]
}, function (err, insertedKeys) {
$description.val('');
if (err) { return console.error(err); }
updateRows(conn);
})
});
});
});