indexed db

17
IndexedDB Designing the API

Upload: parashuram-n

Post on 14-Jan-2015

5.680 views

Category:

Technology


6 download

DESCRIPTION

A refresher on IndexedDB, how the API evolved from its initial versions. Example of LINQ on IndexedDB, IndexedDB-Jquery Plugin and some requirements from IndexedDB

TRANSCRIPT

Page 1: Indexed DB

IndexedDBDesigning the API

Page 2: Indexed DB

Long time ago, in a galaxy far far away …

Page 3: Indexed DB

Applications• Partially Connected Applications– Can work offline also – Email, Calendar, Source Control ?

• Offline Applications– No connection to the internet required–Word processors, todo lists

• Data Caches– Privacy, Save bandwidth,– Shopping carts, user preferences

Page 4: Indexed DB

IndexedDB Example

http://yourwebpage.com search

Database

Cursor on Object Store

Object Storekey : valuekey : valuekey : value

Index

Cursor on Index

Database

Cursor on Object Store

Object Storekey : valuekey : valuekey : value

Index

Cursor on Index

... IndexedDB refresher...

Page 5: Indexed DB

• Transactions : Explicit, auto-commit• Two Flavors – Async on Main browser thread– Sync on Web Workers

... more star wars like text ...

Page 6: Indexed DB

• Cookies – – Limited storage, key value pairs– and the cookie monster

• Local Storage– Not a database, don’t fake it

… days of the old republic …

Page 7: Indexed DB

... restoring balance to the force ...

• Google Gears:Database module– First release: 2007-05-31– Database API based on SQLite – built in

DB

• Web Database API– Dialect of SQLite 3 (ref)– Frozen (ref)

Page 8: Indexed DB

… the birth of a hero …

• WebSimpleDB– ISAM based store – influenced by

Berkley DB– Concepts of Entity Store, Indexes,

Cursors–Most APIs were synchronous– Async models – function callbacks

– Entity Joins, Sequences and Queues

Page 9: Indexed DB

• Implemented in Chrome 12, Firefox 4.0, IE10

• Uniform Requests API• Concrete Asynchronous API• Use Structured Cloning Algorithm

the dojohttp

://nparashuram.com/ttd/IndexedDB/index.html

… the force is strong with this one.…

Page 10: Indexed DB

• Microsoft and Mozilla bless the youngling

• Concept of requests introduced• Security concerns addressed– Authorization section– Privacy Section

• No more joins, sequences, queues• Explicit transactions

… young hero shows promise…

Page 11: Indexed DB

Come over to the dark side*

Page 12: Indexed DB

• NoSQL – Really ? • No, No SQL

– So what should I do for querying ? • You got Cursors, Indexes

– But complex joins ? NoSQL ? • Build something on top, we need least

common denominator

– Fine, here is what I’ve done• SHOW ME

–… Stop talking you will …

… encountering the Sith Lord …

Page 13: Indexed DB

• Language Integrated Query Language• Sounds like english – – from table in database, select something

when some condition and order by something.

• Why NoSQL ? – Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaghhhh– – Just an experiment, how about we team up

and write a SQL wrapper on this and see how it looks like?

http://nparashuram.com/IndexedDB/LINQ/index.html

… what a piece of junk! …

Page 14: Indexed DB

…the ability to speak doesn't make you intelligent …

• Syntax looks verbose • I no Javascript, can I haz Jquery?

• IndexedDB Wrapper on Javascript• Less verbose with use of promises,

implicit operations

http://nparashuram.com/IndexedDB/jquery/index.html

Page 15: Indexed DB

• Multi Column Indexes – aka Joins – Perform union and intersection in JS ?

• Full Text Search– Proposed, but punted to next version

• DB rollback– Versions supported, but no DB version

revert

• Change Tracking and Sync with Server– I need to contact my mothership–the USS

enterprise

… i find your lack of faith disturbing…

Page 16: Indexed DB

• No DOM interaction• Impact of ECMA.Next– IndexedDB module – Promises– Iterators, Generators, Yield support– Save binary blobs– De-structuring assignments [x,y] = [1,2]– Classes as Object Schema

… always in motion is the future …

Page 17: Indexed DB

May the force be with you

@nparashuramhttp://nparashuram.com

http://nparashuram.com/IndexedDB