最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it possible to retrieve a record from parse.com without knowing the objectId - Stack Overflow

programmeradmin7浏览0评论

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
Add a ment  | 

3 Answers 3

Reset to default 2

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.

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

发布评论

评论列表(0)

  1. 暂无评论