You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs: fix docs service for service with msgspec
* docs: add example for creation custom model
* docs: fix title
* docs: clean up wording
---------
Co-authored-by: Cody Fincher <[email protected]>
Copy file name to clipboardExpand all lines: docs/usage/modeling.rst
+55Lines changed: 55 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -242,4 +242,59 @@ Here's how to use these models with the UniqueMixin:
242
242
await session.flush()
243
243
return post
244
244
245
+
246
+
247
+
Customizing Declarative Base
248
+
-----------------------------
249
+
250
+
In case one of the built in declarative bases do not meet your needs (or you already have your own), Advanced Alchemy already supports customizing the ``DeclarativeBase`` class.
251
+
252
+
Here's an example showing a class to generate a server-side UUID primary key for `postgres`:
253
+
254
+
.. code-block:: python
255
+
256
+
from datetime import datetime
257
+
from uuid importUUID, uuid4
258
+
259
+
from advanced_alchemy.base import CommonTableAttributes, orm_registry
0 commit comments