MCPcopy
hub / github.com/piccolo-orm/piccolo / objects

Method objects

piccolo/table.py:1195–1233  ·  view source on GitHub ↗

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]],
    )

Source from the content-addressed store, hash-verified

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(

Callers 15

runMethod · 0.80
runMethod · 0.80
objectsFunction · 0.80
objects_firstFunction · 0.80
getFunction · 0.80
get_relatedFunction · 0.80
get_or_createFunction · 0.80
test_uuid_formatMethod · 0.80
run_transactionMethod · 0.80
run_atomicMethod · 0.80
test_get_allMethod · 0.80

Calls

no outgoing calls

Tested by 15

test_uuid_formatMethod · 0.64
run_transactionMethod · 0.64
run_atomicMethod · 0.64
test_get_allMethod · 0.64
test_offset_postgresMethod · 0.64
test_offset_sqliteMethod · 0.64
test_getMethod · 0.64
test_get_prefetchMethod · 0.64
test_joinsMethod · 0.64