Giter Site home page Giter Site logo

dbosta.js's Introduction

#DBosta.js

###HTML5 localStorage DB usage alike facilitator with JSON format

don't forget to check the demo.html file where there's a full example

##Features

  • standard Javascript support no need for frameworks
  • add/update/delete collections
  • add/update/delete records
  • find records with $and and $or operators (searches words individually with '%*')
  • clear all collections at once
  • checks for browser localStorage compatibility before using it
  • generates unique id small hash and timestamp per record added
  • creates support collection for future info needed or server-side sync control with timestamp
  • controls total size of localStorage based in the browser in usage

##Getting Started Main JSON structure that is used for passing parameters is like {"collection":"bands","$and":{"country":"USA"},"fields":{"country":"U.S.A."}}
"collection" means the collection/table you want to work on, then it comes the operators which can be $and or $or, and at last the fields of the collection to work on at "fields". This is a very basic and easy to follow structure.

In your project you must guarantee that the collection to be used exists, all you have to do is ,

  DBosta.collection("bands");

afterwards you're able to add records(one or many at once), based in noSQL systems you can add fields on the structure at will,

      var objFields = { "collection":"bands", 
                        "fields":{"name":"Faithfull","years":"2001-2010","country":"Portugal"} 
                      }; 
      var strResult = DBosta.register(objFields); 

you can search for records, in this case all bands from the USA,

      var objParams   = { "collection":"bands",
                          "$and":{"country":"USA"}
                        };
      var objResult   = DBosta.find(objParams);
      for (var key in objResult) {
          console.log("> " + objResult[key]._id + " | " + objResult[key].name + " | " + objResult[key].years);
      }

change records which state USA to change it for U.S.A.,

      var objParams   = { "collection":"bands",
                          "$and":{"country":"USA"},
                          "fields":{"country":"U.S.A."}
                        };
      DBosta.change(objParams);

remove all bands from Germany,

      var objParams   = { "collection":"bands",
                          "$and":{"country":"Germany"}
                        };
      DBosta.remove(objParams);

Exposed

Here's the main functions available.

.total() returns total collections in localStorage

.size() returns total bytes used, and predicted maximum allowed based on the browser brand

.tst() returns current timestamp

.id() generates unique hash identifier

.compatibility() checks if browser is compatible with localStorage usage

.collection(objValue) prepares collection usage

.register(objValue) inserts records in collection

.find(objValue) searches records in collection

.change(objValue) updates records in collection

.remove(objValue) deletes records in collection

.clean(objValue) removes collection

.puf(objValue) removes all collections

And the properties.

.vCollection() default created collection

.vArray() default array for collection

.vString() default string for collection

.vDebug() to see all those beautiful messages from console.log

.vTSTCheck() interval general collections timestamp update in seconds, per example for server-side sync control

.vMaxsize() still not being used

##Follow-up Next main feature will be builtin sorting and major next feature in a few months will be to work as well with IndexedDB.

##Further notes Created by joaovieira.com in Planet Earth, at the Universe.

dbosta.js's People

Watchers

Ahdail Netto avatar James Cloos 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.