1 to many relationship in Parse.com using Python Restful API -
i using parse build database.
i have 2 tables: article & comment. article has 1 or many comments
i using parse resful api [parsepy][1] add items
from parse_rest.datatypes import object class article(object): pass class comment(object): pass articleitem = article(title='test', author='john doe') articleitem.save() # have save before can referenced i don't know how achieve 1:n relationship, can show way make this:
from parse_rest.datatypes import object class article(object): pass class comment(object): pass articleitem = article(title='test', author='john doe') # example, data json comments = [] data in incoming_json['comments']: # don't know why, cannot working [comments(**data).save() data in incoming_json['comments]] comment = comments(**data) comment.save() comments.append(comment) articleitem.comments = comments articleitem.save() # have save before can referenced if query, receive:
[<comments:v6pvbspbqt>, <comments:v5jpqprus6>, <comments:hnocxqmuej>,]
Comments
Post a Comment