GithubHelp home page GithubHelp logo

imclab / localdb.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from agnostic/localdb.js

0.0 2.0 0.0 624 KB

Lightweight NoSQL ODM for modern browsers.

Home Page: agnostic.github.io/LocalDB.js

localdb.js's Introduction

LocalDB.js

Lightweight NoSQL ODM for modern browsers.

What is LocalDB.js?

LocalDB.js is a tool that maps the structure of the databases in objects using the localStorage API, no database drivers are required, just add the library and use it!

Useful for web applications, mobile apps or game engines.

Requeriments

A modern browser that supports localStorage.

How To Use

Import the library (Supports AMD)

<script type='text/javascript' src='LocalDB.js'>

Create a collection

var books = new LDB.Collection('books');

Adding documents

var item = {
  author: 'Author name',
  title: 'Book title test'
};

books.save(item, function(_item){
  console.log('New item:', _item);
});

Multiple items

var items = [{
  author: 'Author name',
  title: 'Book title test'
},{
  author: 'Another author',
  title: 'New book'
}];

books.save(items, function(_items){
  console.log('New items:', _items);
});

Find and Update

books.find({ author: 'Author name' }, function(results){
  if(results[0]){
    results[0].author = 'New name';
    results[0].save();
  }
});

Update

books.update({ author: 'Author name' }, function(updated_items){
  console.log(updated_items);
});

Delete

books.find({ author: 'Author name' }, function(items){
  for(var i in items){
    items[i].delete();
  }
});

Drop collection

books.drop();

Drop all collections

LDB.clear();

Show collections

LDB.showCollections();

TODO

Configuration for REST API. Extra functionalities.

localdb.js's People

Contributors

agnostic avatar ckgrafico avatar theoretick avatar

Watchers

JT5D 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.