Add field option for fetch_from

This commit is contained in:
Ege Emir Özkan
2020-08-10 05:32:34 +03:00
parent 951623617c
commit 9cae63bfec
4 changed files with 17 additions and 13 deletions

View File

@@ -62,10 +62,11 @@ inserted onto the system.
> :warning: **Limitation! Fetch can only fetch limited classes correctly**: int, float and str!
Finally, you may wish to recreate objects from a table that already exist, for
this purpose we have the function `fetch_from(class_, object_id)` as well
this purpose we have the function `fetch_from(class_, value, field)` as well
as `is_fetchable(className, object_id)` former fetches a record from the
SQL database whereas the latter checks if it is fetchable (most likely
to check if it exists.)
SQL database given a field and value. If only the value is provided,
field defaults to 'obj_id' which is unique for all objects,
whereas the latter checks if it is fetchable (most likely to check if it exists.)
```python
>>> fetch_from(Student, 2)