See the sample code below - in this case, the objectId for the record I am trying to retrieve is known.
My question is, if I don't know the Parse objectId, how would I implement the code below?
var Artwork = Parse.Object.extend("Artwork");
var query = new Parse.Query(Artwork);
query.get(objectId, {
success: function(artwork) {
// The object was retrieved successfully.
// do something with it
},
error: function(object, error) {
// The object was not retrieved successfully.
// warn the user
}
});
See the sample code below - in this case, the objectId for the record I am trying to retrieve is known.
My question is, if I don't know the Parse. objectId, how would I implement the code below?
var Artwork = Parse.Object.extend("Artwork");
var query = new Parse.Query(Artwork);
query.get(objectId, {
success: function(artwork) {
// The object was retrieved successfully.
// do something with it
},
error: function(object, error) {
// The object was not retrieved successfully.
// warn the user
}
});
Share
Improve this question
asked Oct 17, 2012 at 11:57
vedranvedran
1,1532 gold badges13 silver badges19 bronze badges
1
-
Do you want to get any
Artwork
record? And how many? One, two, all of them? – user94154 Commented Oct 17, 2012 at 12:07
3 Answers
Reset to default 2Query.get() is used when you already know the Parse object id. Otherwise, one can use query.find() to get objects based on the query parameters.
Sure, you can use Parse Query to search for objects based on their properties.
The thing that wasn't clear to me in the documentation is that once you get the object in the query, you would need to do:
With Query (can return multiple objects):
artwork[0].get('someField');
With 'first' or 'get':
artwork.get('someField');
You cannot do something like artwork.someField
like I assumed you would