Giter Site home page Giter Site logo

bucket's Introduction

Bucket.js

Bucket is a cross-browser client-side database solution. Bucket currently supports IndexedDB, WebSQL, and LocalStorage. Bucket was developed by Chegg ME team, and is used heavily in Chegg's eReader.

Creating a bucket instance is dead-simple -

var storage = new Bucket({
    driver_options : {
        table : 'foo'
    },
    drivers : ['IndexedDB'],
    onLoad : function(){},
    onError :function(){}
});

For an extended parameter list, see docs.

By default, bucket chooses the 1st usable driver in it's list (if no driver list was provided to the constructor). This means that the easiest way to set application-wide driver prioritization is simply to control the order in which drivers are defined. However, you can also specify which drivers you want the instance to use (and in which order) by specifying a driver list in the parameters.

Methods

All methods are async, and always receive a callback as the last parameter. Bucket follows the Node.js pattern, where the 1st parameter of a callback is an error object (or null in case no error was generated).

### Bucket.set

```js
//singular
storage.set('a','b');

//plural
storage.set({
    'arieh' : 'glazer',
    'roded' : 'conforty'
});

Bucket.get

//singular
storage.get('a', function(err,value){
    console.log(value);
});

//plural
storage.get(['arieh','roded'], function(err,values){
    console.log(values); //{arieh:'glazer', roded:'conforty'}
});

Bucket.remove

//singular
storage.remove('a');

//plural
storage.remove(['a','arieh']);

Bucket.exists

storage.exists('arieh', function(err, ex){
    console.log(ex);
});

Bucket.each

storage.each(function(err, key, value){
    console.log(key, value);
});

Bucket.getAll

storage.getAll(function(err,map){
    //key value map
});

Bucket.getKeys

storage.getKeys(function(err, keys){
    //array of keys
});

Bucket.getLength

storage.getLength(function(err, len){});

Bucket.clear

storage.clear();

bucket's People

Contributors

arieh avatar nirgeier avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.