Last active
July 30, 2023 00:44
-
-
Save jensarps/5337629 to your computer and use it in GitHub Desktop.
This file contains 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
<script> | |
var dojoConfig = { | |
packages: [ | |
{ | |
name: 'storehouse', | |
location: '../storehouse' | |
} | |
] | |
}; | |
</script> |
This file contains 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
var customerObject = { | |
name: 'John', | |
email: '[email protected]' | |
customerId: 2462345 | |
} | |
var customers = new Storehouse({ | |
storeId: 'customers', | |
idProperty: 'customerId' | |
}); |
This file contains 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
var myStorehouse = new Storehouse({ | |
storeId: 'customers', | |
enginePreference: ['localstorage', 'indexeddb', 'cookie'] | |
}); |
This file contains 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
var dataObject = myStorehouse.get(2); |
This file contains 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
myStorehouse.open().then(function(){ | |
// storehouse now is ready to be worked with | |
console.log('ready!'); | |
}); |
This file contains 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
var dataObject= { | |
id: 15, | |
name: 'John', | |
lastname: 'Doe', | |
age: '57' | |
}; | |
myStorehouse.put(dataObject).then(function(){ | |
// the data now is stored and persisted | |
}); |
This file contains 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
// ...find all items where "prime" is true: | |
var results = store.query({ prime: true }); |
This file contains 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
myStorehouse.remove(15).then(function(){ | |
// the object with id 15 is now deleted from the store | |
}); |
This file contains 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
require(['storehouse/Storehouse'], function(Storehouse){ | |
// use Storehouse | |
var myStorehouse = new Storehouse({ storeId: 'myStore'}); | |
}); |
This file contains 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
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