gpt4 book ai didi

javascript - '失败,错误代码为 : TypeError: Cannot call method 'replace' of undefined' when running Parse query

转载 作者:行者123 更新时间:2023-12-03 11:17:44 26 4
gpt4 key购买 nike

每当我运行 Parse 后台作业时,它就会失败并收到以下错误:

Failed with: TypeError: Cannot call method 'replace' of undefined
at Object.b.Query._quote (Parse.js:3:14236)
at Object.b.Query.contains (Parse.js:3:14337)
at main.js:1491:40
at e (Parse.js:2:5101)
at Parse.js:2:4651
at Array.forEach (native)
at Object.x.each.x.forEach [as _arrayEach] (Parse.js:1:665)
at c.extend.resolve (Parse.js:2:4602)
at null.<anonymous> (Parse.js:2:5181)
at e (Parse.js:2:5101)

这是导致问题的区域,第 1491 行是最后一行:

var MCI_Results = Parse.Object.extend("MCI_Results");



var MCI_Results_Comparison_Query = new Parse.Query(MCI_Results);

// Query for any MCI_Results that have new items

MCI_Results_Comparison_Query.equalTo('parent', parentUser);

MCI_Results_Comparison_Query.contains('searchTerm', searchTermsList[i]);

MCI_Results_Comparison_Query.containedIn('MCItems', top3List[i]);

MCI_Results_Comparison_Query.find()

.then(function(results) {

//No new items

if (results.length > 0) {

console.log("No new items, you're good to go!");

//Add user to the "DON'T send push notification" channel

////////

var installationQuery = new Parse.Query(Parse.Installation);

installationQuery.equalTo('userId', parentUser);


installationQuery.first()

.then(function(result) {

result.set('channels', ["noPush"]);

result.save();

});

///////

console.log('done updating channel');

}

//New items found

else if (results.length === 0) {

console.log('no matching MCI_Results, lets push some new shit');

console.log('searchTermsList[i]:' + searchTermsList[i]);



var MCI_Results_Update_Query = new Parse.Query(MCI_Results);

MCI_Results_Update_Query.equalTo('parent', parentUser);

MCI_Results_Update_Query.contains('searchTerm', searchTermsList[i]);

我在这里所做的只是设置查询的参数,根本不涉及替换方法。是什么导致它指出该错误?我进行了三次检查,确信 searchTermsList[i] 存在,并且 MCI_Results 对象上的 searchTerm 属性也存在。

最佳答案

对我来说,“修复”(我猜“解决方法”更准确)是避免“包含”并使用“containedIn”代替。它应该起作用并不直观,但它似乎可以解决问题。

我猜想,当涉及到数组时,这两种方法都不是它们名称所暗示的真正的集合操作,而只是寻找重叠,因此 contains 和 containsIn 之间没有区别?

关于javascript - '失败,错误代码为 : TypeError: Cannot call method 'replace' of undefined' when running Parse query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27261615/

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