Skip to content

Latest commit

 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

filestore

Store and retrieve objects in/from JSON files

Usage

The easiest way to add a filestore to your project is to add a configuration file to your project and then load this file with ut_use in your application. Here's an example that recursively persists all objects under /data, and stores the files in /tmp/myProjectStore:

filestore.json:

{
  "type": "driver/mnt/filestore/mount",
  "value": {
    "storedir": "/tmp/myProjectStore",
    "query": {
      "select": "//",
      "from": "data"
    },
    "policy.ownership": "LOCAL_SOURCE"
  }
}

By setting policy.ownership to LOCAL_SOURCE, objects in the store will be owned by the application. This ensures that when you restart the application, initial values from persisted objects are overwritten with the latest value from the store.

You can load this file in your application, by doing:

if (ut_use("filestore.json", 0, NULL)) {
    ut_error("%s", ut_lasterr());
}

About

Store and retrieve objects in/from JSON files

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages