Returns a list of table instances (each representing a row), which you can modify and then call 'save' on, or can delete by calling 'remove'. .. code-block:: python pythonistas = await Band.objects().where( Band.name == 'Pythonistas'
(
cls: type[TableInstance],
*prefetch: Union[ForeignKey, list[ForeignKey]],
)
| 1193 | |
| 1194 | @classmethod |
| 1195 | def objects( |
| 1196 | cls: type[TableInstance], |
| 1197 | *prefetch: Union[ForeignKey, list[ForeignKey]], |
| 1198 | ) -> Objects[TableInstance]: |
| 1199 | """ |
| 1200 | Returns a list of table instances (each representing a row), which you |
| 1201 | can modify and then call 'save' on, or can delete by calling 'remove'. |
| 1202 | |
| 1203 | .. code-block:: python |
| 1204 | |
| 1205 | pythonistas = await Band.objects().where( |
| 1206 | Band.name == 'Pythonistas' |
| 1207 | ).first() |
| 1208 | |
| 1209 | pythonistas.name = 'Pythonistas Reborn' |
| 1210 | |
| 1211 | await pythonistas.save() |
| 1212 | |
| 1213 | # Or to remove it from the database: |
| 1214 | await pythonistas.remove() |
| 1215 | |
| 1216 | :param prefetch: |
| 1217 | Rather than returning the primary key value of this related table, |
| 1218 | a nested object will be returned for the row on the related table. |
| 1219 | |
| 1220 | .. code-block:: python |
| 1221 | |
| 1222 | # Without nested |
| 1223 | band = await Band.objects().first() |
| 1224 | >>> band.manager |
| 1225 | 1 |
| 1226 | |
| 1227 | # With nested |
| 1228 | band = await Band.objects(Band.manager).first() |
| 1229 | >>> band.manager |
| 1230 | <Band 1> |
| 1231 | |
| 1232 | """ |
| 1233 | return Objects[TableInstance](table=cls, prefetch=prefetch) |
| 1234 | |
| 1235 | @classmethod |
| 1236 | def count( |
no outgoing calls