Created
January 20, 2013 07:20
-
-
Save hungryzi/4577128 to your computer and use it in GitHub Desktop.
Using superfeedr/indexeddb-backbone-adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defining schema | |
schema = | |
id: 'todos-database' | |
migrations: [ | |
{ | |
version: '1', | |
migrate: (db, req, next) -> | |
store = db.createObjectStore('todos') | |
next(); | |
}, | |
{ | |
version: '2', | |
migrate: (db, req, next) -> | |
store = req.transaction.objectStore('todos') | |
store.createIndex('nameIndex', 'name', unique: false) | |
next() | |
} | |
] | |
# Modifying Backbone objects | |
app.Todos = Backbone.Collection.extend | |
database: schema | |
storeName: 'todos' | |
# ... | |
app.Todo = Backbone.Model.extend | |
database: schema | |
storeName: 'todos' | |
# ... | |
# Querying | |
todos = new app.Todos() | |
todos.fetch | |
conditions: | |
format: ["a", "f"] | |
offset: 10 | |
limit: 5 | |
success: -> | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment