
Security News
Python Adopts Standard Lock File Format for Reproducible Installs
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
backbone-idb
Advanced tools
Backbone IndexedDB adapter with cross browser support via IDBWrapper
IDBWrapper tutorial Part 1 - Basic CRUD
IDBWrapper tutorial Part 2 - Indexes and Query
See tests for usage until I get some more time to fully document.
Available via npm
$ npm install backbone-idb
# or
$ npm install backbone-idb --save # to install and save to package.json
Also available via bower
$ bower install backbone-idb
# or
$ bower install backbone-idb --save # to install and save to bower.json
Define a Backbone.Model
or Backbone.Collection
with an indexedDB
property in the initialize function.
var Note = Backbone.Model.extend({});
var Notes = Backbone.Collection.extend({
initialize: function() {
this.indexedDB = new Backbone.IndexedDB({
storeName: 'notes',
dbVersion: 1,
keyPath: 'id',
autoIncrement: true,
indexes:[
{name:'tags', keyPath:'tags', unique: false, multiEntry: true},
// When specifying only the `name`, `keyPath` is assummed to be the same.
// `unique` and `multiEntry` are also false by default.
// {name:'titleLC', keyPath:'titleLC', unique: false, multiEntry: false}
{name:'titleLC'}
]
}, this);
},
model: Note
});
The first parameter passed into Backbone.IndexedDB is the options
object. You may pass in an empty object and have the default attributes set for the store (defaults listed below). Any options that you pass in will override the defaults.
// The default options object set on the Collection/Model
var options = {
storeName: 'Store',
storePrefix: '',
dbVersion: 1,
keyPath: 'id',
autoIncrement: true,
onStoreReady: defaultReadyHandler,
onError: defaultErrorHandler,
indexes: []
};
Since indexedDB is asynchronous in nature, we need to update the way we instantiate a new Collection or Model. By default, backbone-idb will trigger idb:ready
on the object. This behaviour can be overridden by setting your own callback function on the onStoreReady
attribute in the options object.
var notes = new Notes();
notes.once('idb:ready', function() {
// Some actions to take after initializing the new collection
});
Collections/Models can now use the same Backbone.sync api to interact with IndexedDB; however, you will need to add your own success callback and, optionally, your own error callback in the options parameter.
notes.fetch({success: function() {
// fetch success handler
}});
var note = new Note();
notes.add(note);
note.save({title: 'some note title'}, {success: function() {
// save success handler
}});
index
via the iterate
commandidb-wrapper
via the indexedDB.store
objectFAQs
Backbone IndexedDB adapter with cross browser support via IDBWrapper
The npm package backbone-idb receives a total of 29 weekly downloads. As such, backbone-idb popularity was classified as not popular.
We found that backbone-idb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
Security News
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.