async-easy-model 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: async-easy-model
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: A simplified SQLModel-based ORM for async database operations
5
5
  Home-page: https://github.com/puntorigen/easy-model
6
6
  Author: Pablo Schaffner
@@ -154,12 +154,36 @@ users = await User.insert([
154
154
  {"username": "user2", "email": "user2@example.com"}
155
155
  ])
156
156
 
157
- # Insert with relationships using nested dictionaries
158
- post = await Post.insert({
159
- "title": "My First Post",
160
- "content": "Hello world!",
161
- "user": {"username": "john_doe"} # Will automatically link to existing user
157
+ # Insert with nested relationships
158
+ new_post = await Post.insert({
159
+ "title": "My Post",
160
+ "content": "Content here",
161
+ "user": {"username": "jane_doe"}, # Will automatically link to existing user
162
+ "comments": [ # Create multiple comments in a single transaction
163
+ {"text": "Great post!", "user": {"username": "reader1"}},
164
+ {"text": "Thanks for sharing", "user": {"username": "reader2"}}
165
+ ]
166
+ })
167
+ # Access nested data without requerying
168
+ print(f"Post by {new_post.user.username} with {len(new_post.comments)} comments")
169
+
170
+ # Insert with nested one-to-many relationships
171
+ publisher = await Publisher.insert({
172
+ "name": "Example Publisher",
173
+ "books": [ # List of nested objects
174
+ {
175
+ "title": "Python Mastery",
176
+ "genres": [
177
+ {"name": "Programming"},
178
+ {"name": "Education"}
179
+ ]
180
+ },
181
+ {"title": "Data Science Handbook"}
182
+ ]
162
183
  })
184
+ # Access nested relationships immediately
185
+ print(f"Publisher: {publisher.name} with {len(publisher.books)} books")
186
+ print(f"First book genres: {[g.name for g in publisher.books[0].genres]}")
163
187
  ```
164
188
 
165
189
  ### Read (Retrieve)
@@ -265,22 +289,28 @@ Using the models defined earlier, here's how to work with relationships:
265
289
 
266
290
  ```python
267
291
  # Load all relationships automatically
268
- post = await Post.select({"id": 1}, include_relationships=True)
292
+ post = await Post.select({"id": 1})
269
293
  print(post.user.username) # Access related objects directly
270
294
 
271
295
  # Load specific relationships
272
296
  post = await Post.get_with_related(1, ["user", "comments"])
273
297
 
274
298
  # Load relationships after fetching
275
- post = await Post.select({"id": 1})
299
+ post = await Post.select({"id": 1}, include_relationships=False)
276
300
  await post.load_related(["user", "comments"])
277
301
 
278
- # Insert with related objects in a single transaction
279
- new_post = await Post.insert_with_related({
302
+ # Insert with nested relationships
303
+ new_post = await Post.insert({
280
304
  "title": "My Post",
281
305
  "content": "Content here",
282
- "user": {"username": "john_doe"}
306
+ "user": {"username": "jane_doe"}, # Will automatically link to existing user
307
+ "comments": [ # Create multiple comments in a single transaction
308
+ {"text": "Great post!", "user": {"username": "reader1"}},
309
+ {"text": "Thanks for sharing", "user": {"username": "reader2"}}
310
+ ]
283
311
  })
312
+ # Access nested data without requerying
313
+ print(f"Post by {new_post.user.username} with {len(new_post.comments)} comments")
284
314
 
285
315
  # Convert to dictionary with nested relationships
286
316
  post_dict = post.to_dict(include_relationships=True, max_depth=2)
@@ -325,7 +355,7 @@ db_config.set_connection_url("postgresql+asyncpg://user:password@localhost:5432/
325
355
 
326
356
  ## Documentation
327
357
 
328
- For more detailed documentation, please visit the [GitHub repository](https://github.com/puntorigen/easy_model) or refer to the [DOCS.md](https://github.com/puntorigen/easy_model/blob/main/DOCS.md) file.
358
+ For more detailed documentation, please visit the [GitHub repository](https://github.com/puntorigen/easy-model) or refer to the [DOCS.md](https://github.com/puntorigen/easy-model/blob/master/DOCS.md) file.
329
359
 
330
360
  ## License
331
361
 
@@ -0,0 +1,10 @@
1
+ async_easy_model/__init__.py,sha256=qtmIxVNPohdcmh0KmQT1TArYRQRtA9aVj8RAa5qrApc,1642
2
+ async_easy_model/auto_relationships.py,sha256=V2LAzNi7y-keFk4C_m-byVRM-k_7nL5HEy9Ig3nEdq8,27756
3
+ async_easy_model/migrations.py,sha256=rYDGCGlruSugAmPfdIF2-uhyG6UvC_2qbF3BXJ084qI,17803
4
+ async_easy_model/model.py,sha256=Vq6NTUThuEKy_CVLAb6Dy5pcDjbBr49qgamTQj5GtZ0,63284
5
+ async_easy_model/relationships.py,sha256=vR5BsJpGaDcecCcNlg9-ouZfxFXFQv5kOyiXhKp_T7A,3286
6
+ async_easy_model-0.2.4.dist-info/LICENSE,sha256=uwDkl6oHbRltW7vYKNc4doJyhtwhyrSNFFlPpKATwLE,1072
7
+ async_easy_model-0.2.4.dist-info/METADATA,sha256=kV2oSzYEJ2ac1ScXrWmTjr4EJtO8-e-LQawsBSykr5k,10720
8
+ async_easy_model-0.2.4.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
9
+ async_easy_model-0.2.4.dist-info/top_level.txt,sha256=e5_47sGmJnyxz2msfwU6C316EqmrSd9RGIYwZyWx68E,17
10
+ async_easy_model-0.2.4.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- async_easy_model/__init__.py,sha256=A0U-LtrK9tjK-b94oDNJyc3XFmmnjQAHXP7Bs-FHx18,1642
2
- async_easy_model/auto_relationships.py,sha256=VetxcrOdKGGSImTiysRFR8PSOSlo50RqnVG95CLe8Jg,22433
3
- async_easy_model/migrations.py,sha256=rYDGCGlruSugAmPfdIF2-uhyG6UvC_2qbF3BXJ084qI,17803
4
- async_easy_model/model.py,sha256=TUTTLP47YWCdlsrsyf-7HmMAhPdlvTNZG416pA7UfCo,52958
5
- async_easy_model/relationships.py,sha256=vR5BsJpGaDcecCcNlg9-ouZfxFXFQv5kOyiXhKp_T7A,3286
6
- async_easy_model-0.2.2.dist-info/LICENSE,sha256=uwDkl6oHbRltW7vYKNc4doJyhtwhyrSNFFlPpKATwLE,1072
7
- async_easy_model-0.2.2.dist-info/METADATA,sha256=QcX4beoXLL0fbPJ8ZVMAL4Q5QlXGgJfb4jjSjPx3Yqw,9474
8
- async_easy_model-0.2.2.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
9
- async_easy_model-0.2.2.dist-info/top_level.txt,sha256=e5_47sGmJnyxz2msfwU6C316EqmrSd9RGIYwZyWx68E,17
10
- async_easy_model-0.2.2.dist-info/RECORD,,