Once you have identified a Set of records, you can update directly without
first selecting:
db((table.outID==user_id) &
(table.label==form.vars.customLabel)).update(label=form.vars.customLabel)
That will update all the records in one operation without reading anything
from the database.
Anthony
On Sunday, September 25, 2016 at 4:24:20 AM UTC-4, Annet wrote:
>
> In a table I defined a field:
>
> Field('customLabel', length=128, requires=[IS_LENGTH(32), IS_NOT_EMPTY()]),
>
> When the user updates this field I need the update to cascade to a field
> label
> in another table:
>
> Field('label', length=128, default='', requires=IS_IN_DB(db,
> 'ntw_edge_label_set.customLabel',
> '%(customLabel)s', orderby='ntw_edge_label_set.customLabel')),
>
> The problem is that it should not cascade to all the label fields
> containing the customLabels
> just to the ones related to this specific user.
>
> My first thought was to query the db
>
> rows = db((table.outID==user_id) &
> (table.label==form.vars.customLabel)).select()
> for row in rows:
> row.update_record(label=form.vars.customLabel)
>
>
> I am wondering wether this is the most efficient way to update the records
> or whether
> there is a better way to do this.
>
>
> Kind regards,
>
> Annet
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.