Closed keinagae closed 1 year ago
So in simple terms we can say manager is more like an orm and types or response types and manager does not transform its queries to types correct?
Yes, the ORM part "objects" or "manager" is like an ORM. But it's built from the type
you designed. The reason it doesn't automatically converts it back and forth. It's because you may want to resolve
a "field
" via the field it self or via the whole object with the manager. And this gives you the developer(s) more control on how you resolve each field or object.
P.S. I already started working in a example project.
thanks looking forward to it and one thing can we use pydantic as type and same class as form? i have worked with tortose-orm and beanie and found these to be pretty good and they sit well with pydantic and with that we might get rid of having to create time but still user can create one if he wants to
The tool is in part built with Strawberry, here you can see how to use Pydantic-with-Strawberry but it's an "experimental feature". In fact you can decide to not use the database part I built and instead use Strawberry-Types and then for the database use any tool you prefer.
Example-Project I created an example project. Hopefully it helps! I will try to improve it when I have more free-time.
thanks looking forward to it and one thing can we use pydantic as type and same class as form? i have worked with tortose-orm and beanie and found these to be pretty good and they sit well with pydantic and with that we might get rid of having to create time but still user can create one if he wants to
There's no example project yet. but that's a good idea! I created a video tutorial and a tutorial.
You shouldn't use the one returned by the manager. you need to transform it. The manager is for the database transactions . While types are for the client. For example if 2 tables are related table-1 (Book) and table-2 (Category).
If you reference the Category in the Book table you will do it as "Category" but internally and in the manager. The field you will see for the database side is not "Category" but instead "category_id" that's why you need to transform it back to the type you designed when returning it to the client.
But if your type looks like this.
the return should look something like this.
return types.Book(title="3 little cats", author="John Doe")