简体   繁体   中英

Android: saving data with relation Parse.com

I have a database on Parse.com. There is a table called EventsUsers that contains eventId as string and userId as pointer on user everything looks like this:

eventId : eventId,
userId : {
  __type : "Pointer",
  className : "_User",
  objectId : userId
}

I need to create row in this table, but I don't know how to create the pointer. This is what I have done yet, it creates the row without the pointer.

ParseObject po = new ParseObject("EventsUsers");
po.put("eventId", event.getId());
po.saveInBackground();

You can implement it like this, an example with current user.

ParseObject po = new ParseObject("EventsUsers"); 
po.put("eventId", event.getId()); 
po.put("userid",ParseUser.getCurrentUser();
po.saveInBackground();

Hope this helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM