Created
March 14, 2012 00:14
-
-
Save ericktai/2032886 to your computer and use it in GitHub Desktop.
JS SDK for Relationships
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
/* STACKMOB JS SDK CODE */ | |
//Fetch 'chucknorris' from StackMob. Expand related objects by one level deep | |
var user = new StackMob.User({ username: 'chucknorris' }); | |
user.fetchExpanded(1, success: function(returnedUser) { console.debug(returnedUser.toJSON()); }); | |
/* RETURNED USER JSON */ | |
//Expanded User. Notice how "weapons" is not an array of IDs, but rather an array of full objects | |
{ | |
"username": "chucknorris", | |
"weapons": [ | |
{ | |
"name": "Beard of Death", | |
"upgradelevels": [ | |
1, 2, 3 | |
], | |
"visible": true, | |
"enabled": [ | |
true, false, true | |
], | |
"lastmoddate": 1331683848490, | |
"hitpoints": 5000, | |
"cost": 2235.75, | |
"upgradecosts": [ | |
150.5, 1000.5, 5250.5 | |
], | |
"createddate": 1331683848490, | |
"weapon_id": "4f5fe2084f8f839d180b440a", | |
"settings": [ | |
"ouch", "super ouch", "mega ouch" | |
] | |
}, { | |
"name": "Fists of Fury", | |
"upgradelevels": [ | |
1, 2, 3 | |
], | |
"visible": true, | |
"enabled": [ | |
true, false, true | |
], | |
"lastmoddate": 1331683848490, | |
"hitpoints": 5, | |
"cost": 0.5, | |
"upgradecosts": [ | |
5.5, 10.05, 25.05 | |
], | |
"createddate": 1331683848490, | |
"weapon_id": "4f5fe2084f8f839d180b4409", | |
"settings": [ | |
"ouch", "super ouch", "mega ouch" | |
] | |
} | |
], | |
"lastmoddate": 1331683847111, | |
"age": 50, | |
"createddate": 1331683847111 | |
} |
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
/* STACKMOB JS SDK CODE */ | |
//Fetch 'chucknorris' from StackMob. Expand related objects by one level deep | |
var user = new StackMob.User({ username: 'chucknorris' }); | |
user.fetchExpanded(1, success: function(returnedUser) { console.debug(returnedUser.toJSON()); }); | |
/* RETURNED USER JSON */ | |
//Expanded User. Notice how "weapons" is not an array of IDs, but rather an array of full objects | |
{ | |
"username": "chucknorris", | |
"weapons": [ | |
{ | |
"name": "Beard of Death", | |
"upgradelevels": [ | |
1, 2, 3 | |
], | |
"visible": true, | |
"enabled": [ | |
true, false, true | |
], | |
"lastmoddate": 1331683848490, | |
"hitpoints": 5000, | |
"cost": 2235.75, | |
"upgradecosts": [ | |
150.5, 1000.5, 5250.5 | |
], | |
"createddate": 1331683848490, | |
"weapon_id": "4f5fe2084f8f839d180b440a", | |
"settings": [ | |
"ouch", "super ouch", "mega ouch" | |
] | |
}, { | |
"name": "Fists of Fury", | |
"upgradelevels": [ | |
1, 2, 3 | |
], | |
"visible": true, | |
"enabled": [ | |
true, false, true | |
], | |
"lastmoddate": 1331683848490, | |
"hitpoints": 5, | |
"cost": 0.5, | |
"upgradecosts": [ | |
5.5, 10.05, 25.05 | |
], | |
"createddate": 1331683848490, | |
"weapon_id": "4f5fe2084f8f839d180b4409", | |
"settings": [ | |
"ouch", "super ouch", "mega ouch" | |
] | |
} | |
], | |
"lastmoddate": 1331683847111, | |
"age": 50, | |
"createddate": 1331683847111 | |
} |
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
/* STACKMOB JS SDK CODE */ | |
//Fetch 'chucknorris' from StackMob. Related objects will be represented by an array of IDs | |
var user = new StackMob.User({ username: 'chucknorris' }); | |
user.fetch({ success: function(returnedUser) { console.debug(returnedUser.toJSON());} }); | |
/* RETURNED USER JSON */ | |
{ | |
"username": "chucknorris", | |
"weapons": [ | |
"4f5fe2084f8f839d180b440a", "4f5fe2084f8f839d180b4409" | |
], | |
"lastmoddate": 1331683847111, | |
"age": 50, | |
"createddate": 1331683847111 | |
} |
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
/* STACKMOB JS SDK CODE */ | |
//Fetch 'chucknorris' from StackMob. Related objects will be represented by an array of IDs | |
var user = new StackMob.User({ username: 'chucknorris' }); | |
user.fetch({ success: function(returnedUser) { console.debug(returnedUser.toJSON());} }); | |
/* RETURNED USER JSON */ | |
{ | |
"username": "chucknorris", | |
"weapons": [ | |
"4f5fe2084f8f839d180b440a", "4f5fe2084f8f839d180b4409" | |
], | |
"lastmoddate": 1331683847111, | |
"age": 50, | |
"createddate": 1331683847111 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment