TutorSession
+-- Tutor
+-- Student
+-- Place
+-- TimeSlot
Tutor - Parse User Object
Student - Parse User Object
Place - Parse Custom Object
+-- Building
+-- Location
TimeSlot - Number [ 1 - 8], eight one hour slots availabe for appointment
Last active
August 29, 2015 14:19
-
-
Save aaronksaunders/54535f98a9ef146a7649 to your computer and use it in GitHub Desktop.
Working with Object Relationship in Parse and Ionic Framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addSession() { | |
| var Tutor = Parse.Object.extend("User"); | |
| var tutor = new Tutor(); | |
| tutor.id = "SCV3V0GqRr"; // bryce | |
| var user = Parse.User.current(); | |
| var Place = Parse.Object.extend("Place"); | |
| var place = new Place(); | |
| place.id = "jZ8feoJOAg"; //Computer Lab II | |
| var TutorSession = Parse.Object.extend("TutorSession"); | |
| var myTutorSession = new TutorSession(); | |
| myTutorSession.set("place",place); | |
| myTutorSession.set("user",user); | |
| myTutorSession.set("tutor",tutor); | |
| myTutorSession.save().then(function(_response){ | |
| console.log("myTutorSession.save: " + JSON.stringify(_response,null,2)); | |
| }, function(_error){ | |
| console.log(JSON.stringify(_error)); | |
| }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var TutorSession = Parse.Object.extend("TutorSession"); | |
| var query = new Parse.Query(TutorSession); | |
| // get all related objects | |
| query.include(["user","place","tutor"]); | |
| query.find({ | |
| success: function(_response) { | |
| //console.log("myTutorSession.query: " + JSON.stringify(_response,null,2)); | |
| for (var i = 0; i < _response.length; i++) { | |
| var session = _response[i]; | |
| console.log("user name: " + session.get("user").get("first_name")); | |
| console.log("location name: " + session.get("place").get("Location")); | |
| console.log("tutor name: " + session.get("tutor").get("first_name")); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment