A little correction for any future visitor:
compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s"),
should be:
compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s" %row),
Anyway the solution is great. Thanks a lot.
El miƩrcoles, 12 de septiembre de 2012 00:54:45 UTC+2,
Thanks for the response guys! I'm going with rochabruno's method as it is
the most straightfoward, I hadn't really looked into the compute
capabilities.
On Tuesday, September 11, 2012 3:55:21 PM UTC-7, rochacbruno wrote:
>
> The computation should be
>
> compute= lambda row: "%(username)s-%(song
The computation should be
compute= lambda row: "%(username)s-%(songname)s-%(playlist_name)s" % row
--
db.define_table('likes',
Field('username', 'reference auth_user'),
Field('songname', 'reference songs'),
Field('playlist_name', 'reference playlist'),
Field('unique_key', unique=True, notnull=True, compute= lambda row:
"%(username)s-%(songname)s-%(playlist_name)s"),
)
Now on any
Depends how you are displaying your list to do the liking and unliking.
A few thoughts
Make sure your composite index has the field which filters out the most
records first.
In your controller you may be able to cut out most queries by considering
something like this:
- Hit the DB once an
I went with the unique composite field index method (unique across 3
fields, not just 2), with my database as follows:
db.define_table('likes',
Field('username', 'reference auth_user'),
Field('songname', 'reference songs'),
Field('playlist_name', 'reference playlist'))
if auth.is_log
How about: in 'likes' make a unique composite index of both fields
(created at DB level). Try to insert a record. If it fails (because of
the index) then delete instead.
On Monday, September 10, 2012 11:58:03 PM UTC+1, Mark Li wrote:
>
> I have 3 datatables as follows:
>
>
> db.define_table(
7 matches
Mail list logo