vedran
vedran

Reputation: 1153

Is it possible to retrieve a record from parse.com without knowing the objectId

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.com 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
  }
});

Upvotes: 6

Views: 7122

Answers (3)

pareshgoel
pareshgoel

Reputation: 991

Query.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.

Upvotes: 2

blak3r
blak3r

Reputation: 16536

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

Upvotes: 0

Héctor Ramos
Héctor Ramos

Reputation: 9258

Sure, you can use Parse Query to search for objects based on their properties.

Upvotes: 0

Related Questions