gpt4 book ai didi

javascript - 使用 matchesQuery 并包含两次 parse.com javascript

转载 作者:行者123 更新时间:2023-11-27 23:19:09 25 4
gpt4 key购买 nike

我使用了 include 和 matchesquery 两次,但在第二个 matchesquery 上,不接受该限制。例如,在我的代码中:

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

});

}
}

运行代码后的结果是:

'结果.长度:0"

当我评论第二个匹配查询并选择参数“club”作为第一个匹配查询时

    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 Id : 8kl40HYG9J typeName : club CategoryName : bistro postMagaziaTypeCategory.php:400 Id : 91HGIQFRGj typeName : club CategoryName : disco postMagaziaTypeCategory.php:400 Id : Ddw6S8hl0Z typeName : club CategoryName : cockteil postMagaziaTypeCategory.php:400 Id : LtiIQXxOx6 typeName : club CategoryName : cockteil postMagaziaTypeCategory.php:400 Id : Yp6j0uJLL3 typeName : club CategoryName : bistro postMagaziaTypeCategory.php:400 Id : dMnMugrKfL typeName : club CategoryName : cockteil postMagaziaTypeCategory.php:400 Id : hCDeYHPLO3 typeName : club CategoryName : bistro postMagaziaTypeCategory.php:400 Id : ntrrKiNaFq typeName : club CategoryName : bistro

我想创建像图片上这样的东西: enter image description here

最佳答案

也许是因为您没有正确查询categoryMagazia..

如果您仔细观察第一个代码块,您会尝试查询相同的 Type 两次。

如果你改变这些行

var queryControllerType = new Parse.Query(controllerType);
var queryType = new Parse.Query(Type);
var queryCategoryMagazia = new Parse.Query(Type);

至此

var queryControllerType = new Parse.Query(controllerType);
var queryType = new Parse.Query(Type);
var queryCategoryMagazia = new Parse.Query(CategoryMagazia);

我想你会没事的。

而且很高兴看到人们继续使用 Parse!

祝你编码愉快!

关于javascript - 使用 matchesQuery 并包含两次 parse.com javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35539318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com