Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nitro_datastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
from nitro_datastore.datastore import NitroDataStore
from nitro_datastore.query_builder import QueryBuilder

__version__ = "1.0.1"
__version__ = "1.0.2"
__all__ = ["NitroDataStore", "QueryBuilder"]
21 changes: 10 additions & 11 deletions nitro_datastore/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,13 +1027,17 @@ def filter_list(self, path: str, predicate: Callable[[Any], bool]) -> List[Any]:
return []
return [item for item in value if predicate(item)]

def _wrap_value(self, value: Any) -> Any:
"""Wrap dicts in NitroDataStore, including dicts inside lists."""
if isinstance(value, dict):
return NitroDataStore(value)
elif isinstance(value, list):
return [self._wrap_value(item) for item in value]
return value

def __getitem__(self, key: str) -> Any:
"""Dictionary-style access: data['key']"""
result = self._data[key]
# Wrap nested dicts in NitroDataStore for chained access
if isinstance(result, dict):
return NitroDataStore(result)
return result
return self._wrap_value(self._data[key])

def __setitem__(self, key: str, value: Any) -> None:
"""Dictionary-style assignment: data['key'] = value"""
Expand All @@ -1052,17 +1056,12 @@ def __contains__(self, key: str) -> bool:
def __getattr__(self, name: str) -> Any:
"""Dot notation access: data.key"""
if name.startswith("_"):
# Allow access to private attributes
raise AttributeError(
f"'{type(self).__name__}' object has no attribute '{name}'"
)

if name in self._data:
result = self._data[name]
# Wrap nested dicts in NitroDataStore for chained access
if isinstance(result, dict):
return NitroDataStore(result)
return result
return self._wrap_value(self._data[name])

raise AttributeError(f"'{type(self).__name__}' has no attribute '{name}'")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "nitro-datastore"
version = "1.0.1"
version = "1.0.2"
description = "Schema-agnostic JSON data store with dot notation, chainable queries, bulk operations, and built-in security features"
readme = "README.md"
authors = [
Expand Down