Bongo.js is a library for
storing and querying
structured data on the browser.
Bongo.js
is built on top of IndexedDB,
an HTML5 browser database technology.
If you tried using IndexedDB directly, you might cry.
Using Bongo.js is easy, peasy, lemon squeezy.
if(bongo.supported) {
// Woo hoo!
}
bongo.db({
name: 'zoo',
objectStores: ["animals"]
});
Insert data:
bongo.zoo.animals.insert({
name: "Mr. Polar Bear",
species: "ursus maritimus",
hungry: true,
visitors_eaten: 2
});
Save data:
bongo.zoo.animals.save({
_id: 2
name: 'Happy Flappy Penguin',
species: "aptenodytes forsteri",
hungry: true,
hilarious: true
});
Get a record by its ID:
bongo.zoo.animals.get(1,function(error, animal) {
if(error) return;
console.log('Do something with ' + animal.name);
});
Find a record by some criteria:
bongo.zoo.animals.findOne({
hilarious:true
},function(error,animal) {
if(error) return;
console.log(animal.name + ' is one little hilarious guy.');
});
Find data:
bongo.zoo.animals.find({
hungry: true
},function(error, animals) {
if(error) return;
// Do something with these hungry animals
});