简体   繁体   中英

How can I access and queried object's id using Parse?

I'm trying to get the id of a queried object, how can I do this?

My query:

var query = new Parse.Query(Parse.User);
query.equalTo("username", "user1"); 
query.find({
  success: function(item) {
        console.log(item) // This works
        console.log(item.id) // This is undefined
  }
});

My returned data resembles this in the console:

> f 
  > createdAt : "May 28"
  > _serverData:
    > username: "user1"
    > email: "user1@gmail.com"
  > id: "93jcdn19"

How can I access the id within my javascript code? Thanks.

I believe that returns an array, so you would do console.log(item[0].id)

To print out every object's id you would do something like

for (var index = 0; index < item.length; index++){
    console.log(item[index].id)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM