-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,282 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
# CHANGELOG | ||
|
||
|
||
|
||
## v0.1.0 (2023-09-25) | ||
|
||
### Build | ||
|
||
* build: add py.typed (#3) ([`eb642eb`](https://github.com/nadobando/pydangorm/commit/eb642ebba7cba67b0fc37352776f2f23cedb6330)) | ||
- build: add py.typed (#3) ([`eb642eb`](https://github.com/nadobando/pydangorm/commit/eb642ebba7cba67b0fc37352776f2f23cedb6330)) | ||
|
||
### Feature | ||
|
||
* feat: save and fetch models (#1) ([`8935e4f`](https://github.com/nadobando/pydangorm/commit/8935e4f8ec5c39f300cb7f818000fe8563e21989)) | ||
- feat: save and fetch models (#1) ([`8935e4f`](https://github.com/nadobando/pydangorm/commit/8935e4f8ec5c39f300cb7f818000fe8563e21989)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
## **Introduction** | ||
|
||
`pydangorm` is a robust and user-friendly **asynchronous** ORM (Object-Relational Mapping) system tailored | ||
for [ArangoDB](https://arangodb.com/), a powerful | ||
multi-model NoSQL database. | ||
|
||
`pydangorm` is inspired by `SQLAlchemy`, a popular ORM system for SQL databases, It aims to provide a similar experience | ||
|
||
## **Main Libraries** | ||
|
||
`pydangorm` is built upon the foundation of two primary libraries: | ||
|
||
- **pydantic**: An extremely popular data validation and settings management library for Python. In `pydangorm`, | ||
pydantic is utilized to provide robust model definitions and validation, ensuring that data interactions are clean, | ||
consistent, and error-free. | ||
|
||
- **aioarango**: An asynchronous driver for ArangoDB. It powers the core interactions with the ArangoDB database, making | ||
it possible for `pydangorm` to support asynchronous database operations, ensuring optimized I/O-bound tasks. | ||
|
||
## **Features** | ||
|
||
- **Database Modeling**: Easily define, validate, and interact with your database models. This includes | ||
support for both vertex and edge models (`VertexModel` and `EdgeModel`). | ||
|
||
- **Pythonic Query Building**: Constructing queries for ArangoDB in a **SQLAlchemy** way. With a Pythonic API, you can | ||
effortlessly build complex queries to retrieve or manipulate your data. | ||
|
||
- **Session Management**: Manage your database sessions and connections with ease. Whether it's connecting to the | ||
database or handling transactions, `pydangorm` has got you covered. | ||
|
||
- **Collection Management**: From creating indices to truncating collections, manage all your collection operations | ||
without hassle. | ||
|
||
- **Asynchronous Support**: `pydangorm` is designed for the modern web. With full asynchronous support, your I/O-bound | ||
database tasks will be lightning fast, ensuring your applications remain responsive and scalable. | ||
|
||
- **Lazy Loading**: `pydangorm` supports lazy loading, ensuring that data is only fetched when needed, optimizing | ||
performance and reducing memory usage. | ||
|
||
### **Roadmap** | ||
|
||
- [x] Support for **`AQL Query Building including trversal`** | ||
- [x] Support for **`VertexModel`** and **`EdgeModel`** | ||
- [x] Support for **`VertexModel`** relationships via **`EdgeModel`** | ||
- [x] Support for **`Model Saving and Updating (single instance)`** | ||
- [x] Support for **`Model Saving and Updating (with relations)`** | ||
- [x] Support for **`Model Deletion (single instance)`** | ||
- [x] Support for **`Model Fetching (single instance)`** | ||
- [x] Support for **`Model Fetching with relations and traversal`** | ||
- [x] Support for **`Model Graph CRUD Operations`** | ||
- [ ] Support for **`Model Deletion Cascade`** | ||
- [ ] Support for **`pydantic` `v2.0`** | ||
- [ ] Support for **`Model Back Population`** | ||
|
||
______________________________________________________________________ | ||
|
||
### **Contributions** | ||
|
||
We're actively looking for contributors to help improve pydangorm and expand its capabilities. | ||
|
||
Whether you're a seasoned | ||
developer or just starting out, your contributions are valuable to us. If you have ideas for new features, | ||
optimizations, or simply want to fix a bug, please check our contribution guidelines or reach out. Together, we can make | ||
pydangorm the best ArangoDB ORM for Python! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Get started with `pydangorm` by installing it via pip: | ||
|
||
### **pip** | ||
|
||
```shell | ||
pip install pydangorm | ||
``` | ||
|
||
### **poetry** | ||
|
||
```shell | ||
poetry add pydangorm | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## BaseArangoModel Class Documentation | ||
|
||
### Overview | ||
|
||
The `BaseArangoModel` class forms the foundation for defining models in the `pydango` ORM that represent ArangoDB | ||
entities. It provides core attributes, methods, and configurations to facilitate interactions with ArangoDB. | ||
|
||
### Attributes | ||
|
||
1. **`id`**: An optional unique identifier for the ArangoDB entity. | ||
1. **`key`**: An optional unique key specific to ArangoDB entities. | ||
1. **`rev`**: An optional revision attribute used in ArangoDB for versioning and conflict resolution. | ||
|
||
### Nested Classes | ||
|
||
- **`Config`**: Specifies configurations for the Pydantic model. It fine-tunes model behavior, especially regarding data | ||
validation and serialization. | ||
|
||
- **`Collection`**: Offers collection-specific configurations for the model, customizing its behavior and settings in | ||
relation to ArangoDB collections. | ||
|
||
### Methods | ||
|
||
1. \*\*__init__(self, **data: Any)**: Initializes the model. If session data is provided, it sets the `__session__` | ||
attribute, linking the model to a specific session. | ||
|
||
1. **\_decompose_class(cls, obj: Any)**: Decomposes or serializes the model. Customized to handle the specific needs of | ||
ArangoDB entities. | ||
|
||
1. **\_calculate_keys(self, ...)**: Determines the keys for the model based on inclusion, exclusion, and other criteria. | ||
|
||
1. **from_orm(cls, obj: Any, session=None)**: Constructs a model instance from an ORM object. Handles relationships and | ||
ensures that associated entities are correctly initialized. | ||
|
||
1. \*\*update_forward_refs(cls, **localns: Any)**: Resolves and updates forward references in relationships and fields. | ||
|
||
1. **save_dict(self)**: An abstract method to be implemented in derived classes. It outlines how the model data should | ||
be saved or serialized. | ||
|
||
### Tips for Developers: | ||
|
||
1. When creating a new model, consider extending the `BaseArangoModel`. It offers foundational attributes and methods | ||
tailored for ArangoDB. | ||
1. Always specify relationships correctly. The `__relationships__` and `__relationships_fields__` attributes are central | ||
to the model's operation. | ||
1. If working with forward references, ensure to call the `update_forward_refs` method after all models are defined to | ||
resolve and set up relationships. | ||
1. Implement the `save_dict` method in derived classes to customize data saving or serialization behavior. | ||
|
||
______________________________________________________________________ | ||
|
||
This documentation offers a developer-centric guide to the `BaseArangoModel` class. It is designed to help developers | ||
understand and use the class effectively. Adjustments can be made based on further content or specific requirements. | ||
Would you like to proceed with another section or topic? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
## **`CollectionConfig`** | ||
|
||
The `CollectionConfig` class provides configuration specific to an ArangoDB collection. It defines attributes that | ||
represent various settings and configurations for a collection in ArangoDB, allowing developers to fine-tune collection | ||
behavior. | ||
|
||
### **Attributes** | ||
|
||
- **`name`**: The name of the ArangoDB collection. | ||
- **`type`**: The type of the collection, represented as an enum (`CollectionType`). | ||
- **`sync`**: A boolean indicating whether to synchronize the collection. Default is `False`. | ||
- **`system`**: A boolean indicating if the collection is a system collection. Default is `False`. | ||
- **`key_generator`**: Specifies the type of key generation strategy. Possible values are "traditional" and " | ||
- **`autoincrement`**". Default is "traditional". | ||
- **`user_keys`**: A boolean indicating whether user-generated keys are allowed. Default is `False`. | ||
- **`key_increment`**: An integer specifying the increment value for auto-incrementing keys. | ||
- **`key_offset`**: An integer specifying the offset value for auto-incrementing keys. | ||
- **`shard_fields`**: A list of fields that determine the sharding strategy. | ||
- **`shard_count`**: An integer indicating the number of shards for the collection. | ||
- **`replication_factor`**: An integer specifying the replication factor for the collection. | ||
- **`shard_like`**: A string representing another collection to use as a sharding reference. Available in enterprise | ||
- editions only. | ||
- **`sync_replication`**: A boolean indicating whether to synchronize replication. | ||
- **`enforce_replication_factor`**: A boolean indicating whether to enforce the specified replication factor. | ||
- **`sharding_strategy`**: Specifies the sharding strategy. Possible values include "community-compat", " | ||
enterprise-smart-edge-compat", and "enterprise-smart-edge". | ||
- **`smart_join_attribute`**: A string specifying the attribute used for smart joins. Available in enterprise editions | ||
only. | ||
- **`write_concern`**: An integer indicating the level of write concern for the collection. | ||
- **`sync_schema`**: A boolean indicating whether to synchronize the schema. Default is `False`. | ||
- **`indexes`**: A sequence of index configurations [**`Indexes`**](#indexes) for the collection. Default is an empty list. | ||
|
||
### **Tips for Developers** | ||
|
||
## **Indexes** | ||
|
||
### Overview | ||
|
||
The indexes module offers a suite of classes to define and work with various types of indexes in ArangoDB collections, | ||
optimizing query performance. | ||
|
||
### Indexes | ||
|
||
- **`GeoIndex`**: Define geospatial indexes for querying based on geographical locations. | ||
- **`HashIndex`**: Craft hash indexes for rapid equality-based lookups. | ||
- **`SkipListIndex`**: Ideal for range queries, providing a range-based indexing mechanism. | ||
- **`FullTextIndex`**: Optimize your text-based queries with this full-text search index. | ||
- **`PersistentIndex`**: Ensures the index remains stored on disk for persistence. | ||
- **`TTLIndex`**: Automatically remove documents post a specified time with this Time-To-Live index. | ||
|
||
!!! tip | ||
Tips for Developers | ||
|
||
1. When setting up a collection in ArangoDB through the ORM, utilize the `CollectionConfig` class to customize | ||
collection behavior. | ||
1. Ensure that the `name` attribute is set, as it determines the name of the collection in ArangoDB. | ||
1. If using the enterprise edition of ArangoDB, consider leveraging the enterprise-specific attributes like `shard_like` | ||
and `smart_join_attribute` for advanced configurations. | ||
1. Adjust the `indexes` attribute to define specific indexes on the collection for optimized queries. | ||
1. Determine the nature of your queries to select the appropriate index type. For instance, use GeoIndex for location-based | ||
queries and FullTextIndex for textual searches. | ||
1. Always specify the fields attribute when defining an index, as it determines which fields in the collection the index | ||
applies to. | ||
1. Consider using the `in_background` attribute if you want to create the index without blocking other operations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## **`EdgeModel`** | ||
|
||
Metaclass: **`EdgeMeta`** | ||
|
||
Subclasses: | ||
|
||
- **`BaseArangoModel`** | ||
|
||
### **Overview** | ||
|
||
The **`EdgeModel`** class forms the foundational representation of an edge (relationship) | ||
in ArangoDB within the pydango ORM. | ||
It equips developers with the necessary attributes and methods to define and manage edges effectively. | ||
|
||
### **Attributes** | ||
|
||
- **`id`**: An optional unique identifier for the ArangoDB edge. | ||
- **`key`**: An optional unique key specific to ArangoDB edges. | ||
- **`rev`**: An optional revision attribute used in ArangoDB for versioning and conflict resolution. | ||
- **`from_`**: Represents the starting vertex of the edge. Aliased to **`FROM`** for ArangoDB compatibility. | ||
- **`to`**: Depicts the target vertex of the edge. Aliased to `TO` for compatibility. | ||
- **`Config`**: Inherits from `BaseConfig`, providing **`Pydantic`** model-specific configurations. | ||
- **`Collection`**: A subclass that inherits from **`EdgeCollectionConfig`**, offering edge-specific collection configurations | ||
for the ORM. | ||
|
||
## **`EdgeCollectionConfig`** | ||
|
||
Subclasses: | ||
|
||
- **`CollectionConfig`** | ||
|
||
### Overview | ||
|
||
The **`EdgeCollectionConfig`** class provides configurations tailored specifically for edge collections in ArangoDB. By | ||
extending the base CollectionConfig, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## **`VertexModel`** | ||
|
||
Metaclass: **`VertexMeta`** | ||
|
||
Subclasses: **`BaseArangoModel`** | ||
|
||
### **Overview** | ||
|
||
The `VertexModel` class represents a vertex in the context of the `pydango` ORM. It provides essential attributes, | ||
methods, and configurations for defining and working with vertices in ArangoDB. | ||
|
||
### **Attributes** | ||
|
||
- **`id`**: An optional unique identifier for the ArangoDB vertex. | ||
- **`key`**: An optional unique key specific to ArangoDB vertices. | ||
- **`rev`**: An optional revision attribute used in ArangoDB for versioning and conflict resolution. | ||
- **`edges`**: Represents the edges related to this vertex. Allows for dot-notation access to related edges. | ||
- **`Config`**: Inherits from `BaseConfig`, providing Pydantic model-specific configurations. | ||
- **`Collection`**: Inherits from `VertexCollectionConfig`, offering vertex-specific collection configurations. | ||
|
||
## **Collection** | ||
|
||
### **`VertexCollectionConfig`** | ||
|
||
Subclasses: | ||
|
||
- **`CollectionConfig`** | ||
|
||
### **Overview** | ||
|
||
The `VertexCollectionConfig` class provides specific configurations tailored for vertex collections in ArangoDB. It | ||
extends the base `CollectionConfig` with vertex-centric customizations. |
Oops, something went wrong.