Closed trondhindenes closed 2 months ago
OK, good point - I think that part of the docs can be expanded upon.
With the first
method, the error was because:
# The `first` method doesn't take any args - so this will error:
>>> await Band.objects().first(Band.name == 'Pythonistas')
# The filtering has to be in a where clause:
>>> await Band.objects().where(Band.name == 'Pythonistas').first()
I've made a few changes to this page:
https://piccolo-orm.readthedocs.io/en/latest/piccolo/query_types/objects.html
Let me know if this is any better.
awesome! Yeah I think this will help a lot!
Looking at https://piccolo-orm.readthedocs.io/en/latest/piccolo/query_types/objects.html#fetching-objects, there's nothing to hint to the user that the usage of "get" vs "first" are different. However, their usage is:
It would be good if the docs were expanded with where clauses to give the reader a sense of real-life usage of these methods.