Hello, I would like to use a web2py json service but I am not sure how to create the database query to do what I want to output the correct json.
This is what I have atm: @service.json def places(): project_info = db(db.project_info.id > 0).select(orderby=~db.project_info.id) project_updates = db(db.project_updates.project == db.project_info.id).select(db.project_updates.ALL, orderby=~db.project_updates.id, limitby=(0, 3)) humans = db(db.human_resources.project_id == db.project_info.id).select(db.human_resources.ALL, orderby=db.human_resources.full_name) return project_info, project_updates, humans I would like to have project_updates and humans as sub queries of project_info so they can intertwine with the outputted json. Here is the structure of those tables and how I am calling the data using Javascript any advice is greatly appreciated: *cheers ############ DATABASE STRUCTURE ############### db.define_table('project_info', Field('userinfo', db.auth_user, default=auth.user_id, writable=False, readable=False), Field('project_title', requires=IS_NOT_EMPTY(), notnull=True), Field('twitter', db.twitter, requires=IS_IN_DB(db, db.twitter,'%(screen_name)s')), Field('country', requires=IS_NOT_EMPTY(), notnull=True), Field('province', label='Province/State', requires=IS_NOT_EMPTY(), notnull=True), Field('city', label='City', requires=IS_NOT_EMPTY(), notnull=True), Field('address', label='Address', requires=IS_NOT_EMPTY(), notnull=True), Field('latitude', requires=IS_NOT_EMPTY(), notnull=True), Field('longitude', requires=IS_NOT_EMPTY(), notnull=True), Field('general_info', 'text'), Field('created_on', 'datetime', default=request.now, writable=False, readable=False)) db.define_table('project_updates', Field('userinfo', db.auth_user, default=auth.user_id, writable=False, readable=False), Field('project', db.project_info, requires=IS_IN_DB(db, db.project_info,'%(id)s'), comment='Choose your Project'), Field('title'), Field('update_info', 'text'), Field('created_on', 'datetime', default=request.now, writable=False, readable=False)) db.define_table('human_resources', Field('userinfo', db.auth_user, default=auth.user_id, writable=False, readable=False), Field('project_id', db.project_info, requires=IS_IN_DB(db, db.project_info,'%(id)s'), comment='Choose Project to associate user to'), Field('full_name'), Field('image','upload', label='Avatar', autodelete=True, requires=IS_EMPTY_OR([IS_IMAGE(extensions=('png', 'gif', 'jpg', 'jpeg')), RESIZE(600, 600)])), Field('image_thumb', 'upload', compute=lambda r: THUMB(r['image'])), Field('contact_phone'), Field('contact_cell'), Field('contact_email'), Field('contact_mail_address'), Field('position'), Field('info', 'text'), Field('created_on', 'datetime', default=request.now, writable=False, readable=False)) ########### Javascript ############# $.getJSON("{{=URL(r=request, f='call', args=['json','places'])}}", function(places) { $(places).each(function(i, v) { var place = this; var marker = new google.maps.Marker({ position: new google.maps.LatLng(place[i].latitude, place[i].longitude), map: map, title: place[i].project_title, }); google.maps.event.addListener(marker, 'click', function() { var hidingMarker = currentPlace; var slideIn = function(marker) { $('.headerTabOne').text(place[i].project_title); $('.paraTabOne').text(place[i].general_info); $('.headerTabTwo').text(place[i][v].title); $('.paraTabTwo').text(place[i][v].update_info); $('.date_info').text(place[i][v].created_on); //$('.avatar').prepend("<img src=\"place[i][i].image_thumb\" alt=\"\" align=\"left\">"); $('.infoTabThree').text(place[i][v].info); $('.paraTabThree').text(place[i][v].full_name); -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.