dmc-autostore

dmc-autostore is a Lua module which makes saving JSON-style application and game data painlessly easy because it uses NO API !.

When the app starts you are given an empty "magic" Lua table. You add and remove data in it as you need. Any modifications made anywhere in the data structure will save those changes to JSON. Super simple? Yes ! Super awesome? Definitely !!

It's Full of Awesome!

AutoStore works by tying into some deep Lua "magic" to know when changes to the data structure have taken place. There are a couple of awesome things to mention:

  • First, this functionality is available anywhere in the data structure, no matter how deeply nested it is.

    So the entire JSON structure is supercharged with magic. See an example data structure below.

  • Second, you never have to think about saving data, or duplicate any code for saving data, or ever think about data storage again.

    Just write to the data structure and changes are saved when they need to be.

  • Third, when your app is architected using objects, you can give each object a reference to its little "branch" of the data structure.

    Then the object can read and write to its small part of the structure and AutoStore will manage the storage part for you.

Examples

There are several examples located in the repo under examples/.

github

Download

This module can be freely downloaded from github.com

Simply click on the image to the right

Module Documentation

dmc-autostore API

Details of the API for dmc-autostore.

dmc-autostore Documentation

Here is the full documentation for dmc-autostore.

Getting Started - dmc-autostore

Get up-and-running quickly using dmc-autostore.

Example Data Structure

This is a real-world example of a data structure from one of my applications in the App Store. The entire thing is actively watching for changes!

Imagine that with a key/value storage solution! :)

Shape Monster Data Structure

{
    "app":{"data_format_version":"0.1","app_version":"0.8.7"},
    "users":[
        {
            "info":{"id":""},
            "shapes_data":{
                "circle":{
                    "awards":{"silver":false,"bronze":true,"gold":false},
                    "total":20,
                    "correct":6,
                    "ema":[1,1,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1]
                },
                "square":{
                    "awards":{"silver":true,"bronze":true,"gold":false},
                    "total":18,
                    "correct":12,
                    "ema":[0,1,1,1,0,1,1,1,1,0,1,0,1,0,0,1,1,1]
                },
                "diamond":{
                    "awards":{"silver":false,"bronze":false,"gold":false},
                    "total":0,
                    "correct":0,
                    "ema":[]},
                "heart":{
                    "awards":{"silver":true,"bronze":true,"gold":true},
                    "total":22,
                    "correct":18,
                    "ema":[1,1,1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1,1,0,1,1]
                },
                "crescent":{
                    "awards":{"silver":false,"bronze":false,"gold":false},
                    "total":0,
                    "correct":0,
                    "ema":[]
                },
                "triangle":{
                    "awards":{"silver":true,"bronze":true,"gold":false},
                    "total":17,
                    "correct":10,
                    "ema":[1,1,1,1,1,1,0,1,1,0,0,0,0,0,1,1,0]
                },
                "star":{
                    "awards":{"silver":false,"bronze":true,"gold":false},
                    "total":27,
                    "correct":12,
                    "ema":[0,1,1,1,1,1,0,0,1,0,0,1,1,0,1,0,0,0,0,0,0,1,1,0,1,0,0]
                },
                "rectangle":{
                    "awards":{"silver":false,"bronze":false,"gold":false},
                    "total":11,
                    "correct":3,
                    "ema":[0,1,1,0,1,0,0,0,0,0,0]
                }
            },
            "selections":[
                {"shape":"rectangle","result":"incorrect"},
                {"shape":"triangle","result":"incorrect"},
                {"shape":"square","result":"correct"},
                {"shape":"star","result":"incorrect"},
                {"shape":"heart","result":"correct"},
                {"shape":"star","result":"incorrect"}
            ]
        }
    ]
}