Simple JSON document storage on disk
Project description
JsonDocStore
Simple JSON document storage on disk.
Each document is stored as one file named <key>.json. The document key is the filename stem, not a field inside the JSON body.
If you want to organize documents into different folders, use one JsonDocStore instance per folder. Each instance manages only the JSON files in its own directory.
What It Does
- Stores one JSON document per file.
- Reads documents directly by filename.
- Uses optional in-memory indexes defined in
index.json. - Provides an interactive CLI in
cli.py.
Data Model
get(key)reads<key>.json.insert(key, doc)writes<key>.json.- Valid keys may contain letters, digits,
.,_, and-. No whitespace.
Schema
index.json is optional.
create=Truecreates the directory if needed. It does not createindex.json.index_fieldsdefines which fields are indexed in memory.get(),insert(),delete(), andlist_all()work withoutindex.json.query_by()only works when an index exists. Querying without an index, or on a non-indexed field, raises an error.- Indexes work only on top-level document fields, not nested paths.
Example:
{
"index_fields": ["email", "status"]
}
For example, this works:
{
"email": "alice@example.com",
"profile": {
"city": "Rome"
}
}
- you can index
email - you cannot index
profile.city
CLI
Start the interactive shell:
jsondocstore /path/to/store
Commands:
listprints document filenames onlylistindexesprints indexed fields, or[]if there is noindex.jsonqueryby FIELD VALUEcreateindex FIELDdeleteindex FIELDinsert KEY JSON_DOCUMENTupdate KEY JSON_DOCUMENTdelete KEYexit
Example session:
$ jsondocstore ./data
jsondocstore> insert user-1 '{"username": "alice", "password": "secret1", "role": "admin"}'
jsondocstore> insert user-2 '{"username": "bob", "password": "secret2", "role": "user"}'
jsondocstore> insert user-3 '{"username": "carol", "password": "secret3", "role": "user"}'
jsondocstore> update user-2 '{"username": "bob", "password": "secret2", "role": "admin"}'
jsondocstore> list
[
"user-1.json",
"user-2.json",
"user-3.json"
]
jsondocstore> createindex role
jsondocstore> queryby role user
[
{
"password": "secret2",
"role": "user",
"username": "bob"
},
{
"password": "secret3",
"role": "user",
"username": "carol"
}
]
Library
from jsondocstore import JsonDocStore
store = JsonDocStore("./data", create=True)
store.insert("user-1", {"username": "alice", "password": "secret1", "role": "admin"})
store.insert("user-2", {"username": "bob", "password": "secret2", "role": "user"})
store.insert("user-3", {"username": "carol", "password": "secret3", "role": "user"})
store.update("user-2", {"username": "bob", "password": "secret2", "role": "admin"})
names = store.list_all()
store.create_index("role")
admins = store.query_by("role", "admin")
doc = store.get("user-1")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsondocstore-0.1.0.tar.gz.
File metadata
- Download URL: jsondocstore-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bb28c3cd88566f217a7ad96e218132456e74416200a9c58a579ae9d08406be8
|
|
| MD5 |
7f523ff2edbbc414c576a8c4d34de6b1
|
|
| BLAKE2b-256 |
baecec0dfbf02cc83d0f37a5e299d593913cdeb1361bfb332300c022db1c9d2f
|
Provenance
The following attestation bundles were made for jsondocstore-0.1.0.tar.gz:
Publisher:
publish.yml on mortensi/jsondocstore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsondocstore-0.1.0.tar.gz -
Subject digest:
6bb28c3cd88566f217a7ad96e218132456e74416200a9c58a579ae9d08406be8 - Sigstore transparency entry: 1257290426
- Sigstore integration time:
-
Permalink:
mortensi/jsondocstore@bbacca469a8cad0b07a5af7899dafb7d1f4e0b12 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mortensi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bbacca469a8cad0b07a5af7899dafb7d1f4e0b12 -
Trigger Event:
release
-
Statement type:
File details
Details for the file jsondocstore-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jsondocstore-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2c3fa4306800cb1095b42ccab3c437d9532dcb1d96ac96345fbfc1298c78034
|
|
| MD5 |
934d42641bd6fef5d44f32eb66dcb1c4
|
|
| BLAKE2b-256 |
665bbdbc71c1fc72fe851f46ef2973eba31542057abfb25b5b35b3b816606744
|
Provenance
The following attestation bundles were made for jsondocstore-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on mortensi/jsondocstore
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsondocstore-0.1.0-py3-none-any.whl -
Subject digest:
a2c3fa4306800cb1095b42ccab3c437d9532dcb1d96ac96345fbfc1298c78034 - Sigstore transparency entry: 1257290508
- Sigstore integration time:
-
Permalink:
mortensi/jsondocstore@bbacca469a8cad0b07a5af7899dafb7d1f4e0b12 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mortensi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bbacca469a8cad0b07a5af7899dafb7d1f4e0b12 -
Trigger Event:
release
-
Statement type: