Giter VIP home page Giter VIP logo

lscollection's Introduction

LS Collection

Manage browser localStorage key as an object collection.

Usages

<script src="ls-collection.js"></script>

Methods

  • insert
  • getAll
  • find
  • findWhere
  • where
  • update
  • delete
  • flash

Create an instance of lsCollection

var todos = new lsCollection('todos');

insert - it returns inserted object

todos.insert({title:"Task 01",status:0})
//output: {title:"Task 01", status:0, _id:1595166010878}
todos.insert({title:"Task 02",status:1})
//output: {title:"Task 02", status:1, _id:1595165132214}

getAll - it returns an array, returns an empty array when no data exist.

todos.getAll()
/** output: 
  [
    {title:"Task 01", status:0, _id:1595166010878},
    {title:"Task 02", status:1, _id:1595165132214}
  ]
**/

find - it returns an object, returns undefined when data not found.

todos.find(1595166010878) // pass unique identifier _id
//output: {title:"Task 01", status:0, _id:1595166010878}

findWhere - it returns an object, returns undefined when data not found.

todos.find({_id:1595166010878})
//output: {title:"Task 01", status:0, _id:1595166010878}

where - it returns an array, returns an empty array when data not found.

todos.find({status:1})
//output: [{title:"Task 02", status:1, _id:1595165132214}]

update - it returns an object, returns false when data not found.

todos.update(1595165132214,updateObjData)
//output: [{title:"Task 02 updated", status:1, _id:1595165132214}]

delete - it returns true/false.

todos.delete(1595166010878)
//output: true

flash - it deletes all data with localstorage key and returns nothing.

todos.flash()

lscollection's People

Contributors

haruncpi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.