Domanda

Ho un oggetto matchCenterItem nel mio codice cloud Parse con proprietà come categorieD, Minprice, ecc. Quello che voglio fare è iterare attraverso ogni istanza di matchCenterItem che un utente ha, quindi fare riferimento alle proprietà specifiche del codice.Quindi qualcosa del genere:

Parse.Cloud.define("MatchCenterTest", function(request, response) {

  var matchCenterItem = Parse.Object.extend("matchCenterItem");  
  for (let i of matchCenterItem) {
         console.log(i.categoryId);
         console.log(i.minPrice);
  }

  success: function (httpResponse) {

          console.log('It worked!');
          response.success('Yay!');

  },
          error: function (httpResponse) {
              console.log('error!!!');
              response.error('Request failed');
          }
});
.

Questo è ovviamente sbagliato, non sono sicuro di come formare la sintassi per realizzarlo correttamente.

È stato utile?

Soluzione

Dovrai interrogare la classe per guardare il contenuto:

Parse.Cloud.define("MatchCenterTest", function(request, response) {

  var query = new Parse.Query("MatchCenterTest");
  query.limit(10);
  query.find().then(function(results) {
    for (i=0; i<results.length; i++) {
     console.log(results[i].get('categoryId'));
     console.log(results[i].get('minPrice'));
    }
    response.success('Cool');
  }, function(error) {
    response.error('Uncool');
  });

});
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top