Giter Site home page Giter Site logo

kucukkanat / localdb Goto Github PK

View Code? Open in Web Editor NEW
74.0 74.0 4.0 1.94 MB

MongoDB on the browser. A database using Javascript localStorage

License: MIT License

JavaScript 100.00%
javascript javascript-localstorage localdb localdb-instance localstorage localstorage-adapter localstorage-api localstorage-wrapper

localdb's Introduction

Hi there ๐Ÿ‘‹ I am HT

localdb's People

Contributors

dependabot[bot] avatar kucukkanat avatar yasinuslu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

localdb's Issues

db.insert should return auto-generated id

If id key is required for further interactions with that "document", whether db.insert() must throw an exception or generate a random id (as it does now) but return that auto-generated id if we omit that field.

Where is API documentation?

Where is the API documentation? Simple .insert, query and remove is on the README.md but we need full API.

Insert with preferred id

Hi,

The document reads as follows
If object has an .id property,
However, if I have id or _id or .id it always generate id its own. It is possible to create with my own id?

How to clear whole database?

I created a database with

foo = new DB('foo');
bar = new DB('bar');

and now I need to purge/delete/vanish whole foo database but keep bar database. How can I do that?

Upsert functionality

Hi,

I like to have upsert function something like the below. Can this be added, please?

This code will take json as param, and then will check if already exists, if not it will do the insert operation based on the given id. If already exist, then it will upate.

  upsert(object) {
    if(object.id === undefined)
    {
      object.id = guid()
    }
    const foundObjects = sift({id: object.id}, JSON.parse(localStorage[this.name]));
    if(foundObjects.length==0)
    {
      let table = JSON.parse(localStorage[this.name])
      table.push(object)
      localStorage[this.name] = JSON.stringify(table)
      this.emit('$insert',object)
      this.emit('$create',object)
      return object
    }
    return this.update({id: object.id}, object);
  }

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.