On Monday, March 13, 2017 at 6:08:32 AM UTC-7, Leonel Câmara wrote:
>
> I actually like to have a list:reference on the table being tagged but
> also have a table relating tags and the tagged table, This doesn't respect
> data normalisation but makes things quite more efficient.
>
>
Thanks! The first reading tells me that it looks easy!
/dps
> To give an example:
> db.define_table('tag',
> Field('name'),
> Field('count', 'integer', writable=False, default=0),
> )
>
> db.define_table('blogpost',
> Field('title'),
> Field('body'),
> Field('tags', 'list:reference tag')
> )
>
>
> db.define_table('blogpost_tag',
> Field('blogpost', 'reference blogpost'),
> Field('tag', 'reference tag'),
> )
>
>
> I then define _after_insert, _after_update and _before_delete functions
> for blogpost so I keep the blogpost_tag table updated when a blogpost is
> changed or inserted.
>
> This makes it very efficient to both search using a given tag and to know
> which tags a blogpost has.
>
>
--
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.