A lightweight clientside JSON document store,

Related tags

Storage lawnchair
Overview
	.____                                 .__            .__         
	|    |   _____  __  _  ______   ____  |  |__ _____   |__|_______ 
	|    |   \__  \ \ \/ \/ /    \_/ ___\ |  |  \\__  \  |  |\_  __ \
	|    |___ / __ \_\     /   |  \  \___ |   Y  \/ __ \_|  | |  | \/
	|_______ (____  / \/\_/|___|  /\___  >|___|  (____  /|__| |__|   
	        \/    \/            \/client\/ json\/store\/ 

To learn more visit http://brian.io/lawnchair or check out the ./doc folder in this repo.

Comments
  • Use 'id' as key

    Use 'id' as key

    Adding the ability to use 'id' as the record key instead of manually specifying 'key' before save()'ing.

    The rationale is that if I'm receiving data from the backend server, it's more likely that the primary key is named 'id' than it is named 'key', so this patch handles that.

    I've only patched the adapters for memory, dom, webkit-sql and indexeddb though.

    Tests included

    opened by ruiwen 8
  • JSON.parse(window.top.name) can cause all JS to stop executing

    JSON.parse(window.top.name) can cause all JS to stop executing

    We just had a major issue on the site due to this bug. in the 'window-name' adapter, there is a call:

    data = window.top.name ? JSON.parse(window.top.name) : {}

    when the window.top.name is not valid json, this will throw an exception which causes all JS loaded after this to fail.

    fix is:

    var data; try { data = window.top.name ? JSON.parse(window.top.name) : {} } catch(e){ data = {}; }

    bug 
    opened by mkoryak 8
  • Callback for all() on a freshly init Lawnchair Object never get called

    Callback for all() on a freshly init Lawnchair Object never get called

    System: WebOS 1.4.5 (both emulator and device)

    Steps to reproduce: In a new scene (e.g. test-assistant.js) function TestAssistant(args) { this.test = new Lawnchair({name: "test", table: "testTable", adaptor: "webkit"}); } TestAssistant.prototype = { setup: function() {

         this.testDb.all(function(r) {
            Mojo.Log.info("Got items from DB: ", r.length);
            this.setupItemsHandler(r);
        }.bind(this));
    }
     }
    

    The "this.setupItemsHandler()" is not called, so I don't know if the DB is empty, to fetch some data or just stick with the DB entries. If I swipe back a scene and call the scene again, the handler is called and the log says e.g. "Got items from DB: 0" If the DB has already some objects, than all runs fine from the beginning, it seems this behavior is only on a new created Lawnchair.

    This issue is always reproducable.

    opened by rretsiem 8
  • IndexedDB adaptor

    IndexedDB adaptor

    Firefox has indicated they will not implement web sql database, but will instead add IndexedDB. Chrome will have both. Safari and Opera support web sql database and havent said anything about Indexeddb. IE is eternally vague.

    http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/ http://hacks.mozilla.org/2010/06/beyond-html5-database-apis-and-the-road-to-indexeddb/

    The lawnchair API appears to play very nicely with IndexedDB. Does it make sense to add an adaptor?

    opened by paulirish 8
  • multiple tables crash?

    multiple tables crash?

    For each table created a new instance of database is also created. Performance becomes a dog, can't even run on iPhone. This is using the WebKitSQLite adapter.

    To repo:

    var _tableone = new Lawnchair('one');
    var _tabletwo = new Lawnchair('two');
    var _tablethree = new Lawnchair('three');
    

    Using web inspector note three DB instances.

    opened by pjepsen 7
  • Specify an array of preferred adapters

    Specify an array of preferred adapters

    I've added a possibility to pass an array of preferred adapter when creating a new Lawnchair object

    var store = new Lawnchair({
      name:'testing', 
      adapter: ['indexed-db', 'webkit-sqlite', 'dom'] }, 
      function(store) {
        // callback
    });
    

    Lawnchair will initialize the first installed and valid adapter from the array, independently of the order in with the adapters were loaded. This permits to control fallback adapters much more easily.

    opened by lukaszfiszer 6
  • No way to tell if an item exists

    No way to tell if an item exists

    As far as I can tell (I may be missing something), there is no way to check if an object with a given key exists.

    get() and find() never call the callback in the case where no object exists. Since callbacks are asynchronous, there is no logical point where application code could check to see if it has received a result or not from any of these calls.

    I think that either get() should call you back (with null), or there should be an exists() method added for this purpose.

    I can use all() for the moment as a workaround, but obviously that is inefficient for large stores.

    My use case is that I want to create a default object if none exists with the given key, but I don't want to simply save() one since that would overwrite an existing object.

    opened by timbertson 6
  • Adding support for Bower package manager

    Adding support for Bower package manager

    Bower is as the creators ( Twitter ) say : THE BROWSER PACKAGE MANAGER html, css, and javascript http://twitter.github.com/bower/

    Under "Authoring packages" you can see that you only need to add this component.json file and once is pushed to the git repository run this command:

    bower register skeleton https://github.com/dhgamache/Skeleton.git

    This will allow anyone on bower to do a "bower search skeleton" and find this package, and install it with a "bower install skeleton".

    In the meanwhile i'm installing from the url in github.

    opened by javifr 5
  • Type erasure when pulling from lawnchair

    Type erasure when pulling from lawnchair

    Disclaimer: I am new to js and lawnchair, so it is entirely possible this is a silly mistake I am making.

    When I save objects to my lawnchair instance, they are typed with a custom type that I defined in previous code. When I access the object from the lawnchair store, it is of type Object.

    How can I ensure when I access the object it maintains my original type?

    Thanks!

    opened by jaker 5
  • I think the code uses the function indexOf of array, and is not implemented in IE 8

    I think the code uses the function indexOf of array, and is not implemented in IE 8

    I'm not sure if this project target IE 8, but if that's the case I believe there are 2 options: or add a dependency with underscore.js, o just copy the undescore implementation of array.indexOf

    opened by nicogranelli 5
  • WebSite tutorial not up to date ?

    WebSite tutorial not up to date ?

    It seems the tutorial available here http://blog.westcoastlogic.com/lawnchair/ isn't up to date.

    Constructor seems to expect an object with adaptor member set to the adaptor required and the example reads:

    var people = new Lawnchair('people');

    Expecting some kind of identifier...

    A complete working example (including required includes) would help. Any plan to update the website ? I could help if you need it...

    opened by warpdesign 5
  • this lib is not working correctly with Typescript

    this lib is not working correctly with Typescript

    There is no declaration file for this package. Causes error in case of using with typescript import. The types field is missed in package.json, it could be something like:

    "types": "./lib/lawnchair.d.ts",
    

    The lawnchair.d.ts file itself need only to declare Lawnchair

    import 'lawnchair'
    
    declare module 'lawnchair' {
      export default function Lawnchair(config: Object, callback: Function): void;
    }
    
    opened by KseniaKapnik 1
  • Website is broken

    Website is broken

    Hi Brian,

    Your website is broken. The following error comes up on every page of lawnchair: {"message":"Missing Authentication Token"}

    opened by MitchellBouwman 0
  • Website is broken

    Website is broken

    Hi Brian,

    Your website is broken. The following error comes up on every page of lawnchair: {"message":"Missing Authentication Token"}

    opened by MitchellBouwman 3
  • Object doesn't support property or method 'exists'

    Object doesn't support property or method 'exists'

    Getting this error in IE11 and Firefox 45.0.1

    TypeError: store.exists is not a function

    `var store = new Lawnchair({table:'pda'}, function(obj) { console.log(obj); });

    store.save({key:'config', company:'A Company'});

    store.exists('config', function(keys) { console.log('Existence is: ' + keys); }); `

    opened by lperry65 0
Releases(0.6.4)
Owner
Brian LeRoux
Currently building https://begin.com with https://arc.codes ✨🔰
Brian LeRoux
Store your data in the world's fastest and most secure storage, powered by the blockchain technology⚡️

Store your data in the world's fastest and most secure storage, powered by the blockchain technology.

BlockDB 3 Mar 5, 2022
A simple, lightweight JavaScript API for handling browser cookies

JavaScript Cookie A simple, lightweight JavaScript API for handling cookies Works in all browsers Accepts any character Heavily tested No dependency S

null 20.2k Jan 3, 2023
A lightweight vanilla ES6 cookies and local storage JavaScript library

?? CrumbsJS ?? A lightweight, intuitive, vanilla ES6 fueled JS cookie and local storage library. Quick Start Adding a single cookie or a local storage

null 233 Dec 13, 2022
Lightweight Angular module for access to cookies

angular-cookie Lightweight Angular module for access to cookies Installation You can install angular-cookie via bower bower install angular-cookie Ot

Ivan Pusic 269 Oct 5, 2022
Zero clientside JavaScript Wordle clone, using Eleventy Edge

Eleventy Edge Wordle Yet another Wordle clone Play the hosted Wordle game! Recently, the Eleventy started unveiling its Eleventy Edge plugin, which al

Ben Myers 20 Oct 6, 2022
The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)

Ajv JSON schema validator The fastest JSON validator for Node.js and browser. Supports JSON Schema draft-06/07/2019-09/2020-12 (draft-04 is supported

Ajv JSON schema validator 12k Jan 4, 2023
JCS (JSON Canonicalization Scheme), JSON digests, and JSON Merkle hashes

JSON Hash This package contains the following JSON utilties for Deno: digest.ts provides cryptographic hash digests of JSON trees. It guarantee that d

Hong Minhee (洪 民憙) 13 Sep 2, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 2022
JSON Hero is an open-source, beautiful JSON explorer for the web that lets you browse, search and navigate your JSON files at speed. 🚀

JSON Hero makes reading and understand JSON files easy by giving you a clean and beautiful UI packed with extra features.

JSON Hero 7.2k Jan 9, 2023
Successor of the flowchart-fun syntax. Store tabular data and graph information in the same document.

graph-selector-syntax A syntax for storing graphs and tabular data in plain text View Examples Installation npm install graph-selector Usage import {

Tone Row 32 Dec 15, 2022
A tool to document your package.json scripts

why A tool to document your package.json scripts Why why? As your project grows you add more scripts to package.json. When a new member joins the proj

Dragoș Străinu 13 Sep 22, 2022
A tool to document your package.json scripts

why A tool to document your package.json scripts Why why? As your project grows you add more scripts to package.json. When a new member joins the proj

Planable Inc. 13 Sep 22, 2022
Document Typescript React components with TSDoc and export Storybook-friendly JSON 🤖

✨ Document React components with @prop ✨ react-tsdoc ?? react-tsdoc is an tool to extract information from React Typescript component files with TSDoc

Noah Buscher 13 Oct 15, 2022
Random Fractals stash of Observable Data Tools 🛠️ and Notebooks 📚 in ES Modules .js, .nb.json, .ojs, .omd, .html and .qmd document formats for Data Previews

Random Fractals stash of Observable Data Tools ??️ and Notebooks ?? in ES Modules .js, .nb.json, .ojs, .omd, .html and .qmd document formats for Data Previews in a browser and in VSCode IDE with Observable JS extension, Quarto extension, and new Quarto publishing tools.

Taras Novak 14 Nov 25, 2022
Microsoft-store - Microsoft Store package for LTSC.

Microsoft Store Microsoft Store package for Windows LTSC. Usage Just download the release and double click the exe file. Can be used in Windows LTSC 2

fernvenue 7 Jan 2, 2023
Lightweight (zero dependencies) library for enabling cross document web messaging on top of the MessageChannel API.

Lightweight (zero dependencies) library for enabling cross document web messaging on top of the MessageChannel API.

LironH 4 Jul 15, 2022
AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.

Please use version 1.x as prior versions has a security flaw if you use user generated data to concat your SQL strings instead of providing them as a

Andrey Gershun 6.1k Jan 9, 2023
Json-parser - A parser for json-objects without dependencies

Json Parser This is a experimental tool that I create for educational purposes, it's based in the jq works With this tool you can parse json-like stri

Gabriel Guerra 1 Jan 3, 2022
Pretty-print-json - 🦋 Pretty-print JSON data into HTML to indent and colorize (written in TypeScript)

pretty-print-json Pretty-print JSON data into HTML to indent and colorize (written in TypeScript) 1) Try It Out Interactive online tool to format JSON

Center Key 87 Dec 30, 2022