但是,我使用include和matchesquery兩次,但在第二次matchesquery中,不接受限制。例如,在我的代碼:使用matchesQuery幷包含兩次parse.com javascript
function findMe(){
var controller = Parse.Object.extend("Controller");
var controllerType = Parse.Object.extend("ControllerType");
var Type = Parse.Object.extend("TypeMagazia");
var CategoryMagazia = Parse.Object.extend("CategoryMagazia");
var queryControllerType = new Parse.Query(controllerType);
var queryType = new Parse.Query(Type);
var queryCategoryMagazia = new Parse.Query(Type);
//start type
var typeTable = [];
var cafebar = document.getElementById('cafe_bar');
var club = document.getElementById('club');
var restaurant = document.getElementById('restaurant');
var pistes = document.getElementById('pistes');
//perasma value ston pinaka
if(cafebar.checked){ typeTable.push(cafebar.value);}
if(club.checked){ typeTable.push(club.value);}
if(restaurant.checked){ typeTable.push(restaurant.value);}
if(pistes.checked){ typeTable.push(pistes.value);}
console.log(typeTable);
//start category
var categoryTable = [];
for(var i =0; i<5; i++){
var cat = "cat"+i;
console.log(cat);
var category = document.getElementById(cat);
//perasma value ston pinaka
if(category.checked){ categoryTable.push(category.value);}
}
console.log(categoryTable);
for (var i = 0; i<typeTable.length; i++){
for (var j = 0; j<categoryTable.length; j++){
queryControllerType.exists('objectId');
queryType.equalTo("TypeName", typeTable[i]);
queryCategoryMagazia.equalTo("CategoryName", categoryTable[j]);
queryControllerType.include('TypeMagaziaID');
queryControllerType.include('CategoryMagaziaID');
queryControllerType.matchesQuery('TypeMagaziaID', queryType);
queryControllerType.matchesQuery('CategoryMagaziaID', queryCategoryMagazia);
queryControllerType.ascending('objectId')
queryControllerType.find().then(function(results) {
console.log("results.length : "+results.length);
for (var k = 0; k < results.length; k++) {
var object = results[k];
var typeB = object.get('TypeMagaziaID');
var catB = object.get('CategoryMagaziaID');
var nameType = typeB.get("TypeName");
var nameCategory = catB.get("CategoryName");
console.log(" Id : "+object.id +" typeName : "+nameType +" CategoryName : "+nameCategory);
}
});
}
}
運行代碼後的結果是:
「results.length:0"
當我評論第二matchesquery和既然選擇參數」俱樂部「成爲第一matchesquery
queryControllerType.exists('objectId');
queryType.equalTo("TypeName", typeTable[i]);
queryCategoryMagazia.equalTo("CategoryName", categoryTable[j]);
queryControllerType.include('TypeMagaziaID');
queryControllerType.include('CategoryMagaziaID');
queryControllerType.matchesQuery('TypeMagaziaID', queryType);
//queryControllerType.matchesQuery('CategoryMagaziaID', queryCategoryMagazia);
queryControllerType.ascending('objectId')
queryControllerType.find().then(function(results) {
console.log("results.length : "+results.length);
for (var k = 0; k < results.length; k++) {
var object = results[k];
var typeB = object.get('TypeMagaziaID');
var catB = object.get('CategoryMagaziaID');
var nameType = typeB.get("TypeName");
var nameCategory = catB.get("CategoryName");
console.log(" Id : "+object.id +" typeName : "+nameType +" CategoryName : "+nameCategory);
}
});
我服用這些結果:
results.length:8 postMagaziaTypeCategory.php:400編號:8kl40HYG9J 的typeName:球杆類別名稱:小酒館postMagaziaTypeCategory.php:400 編號:91HGIQFRGj的typeName:球杆類別名稱:迪斯科 postMagaziaTypeCategory.php:400編號:Ddw6S8hl0Z的typeName :俱樂部 類別名稱:cockteil postMagaziaTypeCategory.php:400編號: LtiIQXxOx6的typeName:俱樂部類別名稱:cockteil postMagaziaTypeCategory.php:400編號:Yp6j0uJLL3的typeName:俱樂部 類別名稱:小酒館postMagaziaTypeCategory.php:400編號:dMnMugrKfL 的typeName:俱樂部類別名稱:cockteil postMagaziaTypeCategory.php:400 ID:hCDeYHPLO3的typeName:俱樂部 類別名稱:小酒館postMagaziaTypeCategory.php:400編號:ntrrKiNaFq 的typeName:俱樂部類別名稱:小酒館
非常感謝您的幫助!對此,我真的非常感激!這是我在過去2天想要弄清楚的!你的觀察對我很有幫助。 –