Skip to content

Instantly share code, notes, and snippets.

@jensarps
Last active July 30, 2023 00:44
Show Gist options
  • Save jensarps/5337629 to your computer and use it in GitHub Desktop.
Save jensarps/5337629 to your computer and use it in GitHub Desktop.
<script>
var dojoConfig = {
packages: [
{
name: 'storehouse',
location: '../storehouse'
}
]
};
</script>
var customerObject = {
name: 'John',
email: '[email protected]'
customerId: 2462345
}
var customers = new Storehouse({
storeId: 'customers',
idProperty: 'customerId'
});
var myStorehouse = new Storehouse({
storeId: 'customers',
enginePreference: ['localstorage', 'indexeddb', 'cookie']
});
var dataObject = myStorehouse.get(2);
myStorehouse.open().then(function(){
// storehouse now is ready to be worked with
console.log('ready!');
});
var dataObject= {
id: 15,
name: 'John',
lastname: 'Doe',
age: '57'
};
myStorehouse.put(dataObject).then(function(){
// the data now is stored and persisted
});
// ...find all items where "prime" is true:
var results = store.query({ prime: true });
myStorehouse.remove(15).then(function(){
// the object with id 15 is now deleted from the store
});
require(['storehouse/Storehouse'], function(Storehouse){
// use Storehouse
var myStorehouse = new Storehouse({ storeId: 'myStore'});
});
var places = new Storehouse({
storeId: 'places'
});
places.open().then(createComboBox);
function createComboBox(){
// create a combobox widget
comboBox = new ComboBox({
id: "placesSelect",
name: "placesSelect",
store: places, // <-- use Storehouse as data store for this widget
searchAttr: "name"
}, "placesSelect");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment