如何在 Parse Cloud Code 上使用 Javascript SDK 克隆解析查询? [英] How can I clone a Parse Query using the Javascript SDK on Parse Cloud Code?

查看:49
本文介绍了如何在 Parse Cloud Code 上使用 Javascript SDK 克隆解析查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想克隆查询,因为它可以帮助我更好地构建代码.但是,当我尝试克隆查询时,我收到一条错误消息:Object [object Object] has no method 'skip'.这是我试过的代码:

I want to clone queries because it helps me structure my code better. But, when I try to clone an query, I get an error saying: Object [object Object] has no method 'skip'. Here's the code I've tried:

var _ = require('cloud/modules/lodash'); // custom lodash 4.0.0
...
var query = new Query('Class');

var clonedQuery = _.clone(query);        // .cloneDeep() doesn't work either
clonedQuery.skip(i);                     // succeeds in unit tests but fails on cloud code
var clonedQuery.first();

注意:下划线 _ 实际上是 lodash 4.0.0,我手动捆绑了我的源代码,而不是云模块来自解析.

Note: The underscore _ is actually lodash 4.0.0 that I've manually bundled with my source code, not the cloud module from Parse.

我不清楚为什么会失败——这里是 lodash 进行克隆,所以我的本地单元测试节点环境和 V8 Cloud Code 环境应该没有区别.

It's not clear to my why this is failing — it's lodash doing the cloning here, so there should be no difference between my local unit testing node environment and the V8 Cloud Code environment.

我在这里使用的是 Parse SDK 1.3.1.解决方法是升级.见下文.

I was using Parse SDK 1.3.1 here. Solution is to upgrade. See below.

推荐答案

_.clone() 实际上适用于 Parse SDK 1.6.14 中的 Query,但不适用于在我使用的 1.3.1 上.我不知道你可以使用parse jssdk工具自己管理Parse JS SDK版本!

_.clone() actually does work for Query in Parse SDK 1.6.14, but not on 1.3.1, which I was using. I didn't know that you can manage the Parse JS SDK version yourself using the parse jssdk tool!

我的解决方案只是更新 SDK.请参阅此处的讨论:https://github.com/ParsePlatform/Parse-SDK-JS/问题/171

The solution for me was simply to update the SDK. See the discussion here: https://github.com/ParsePlatform/Parse-SDK-JS/issues/171

这篇关于如何在 Parse Cloud Code 上使用 Javascript SDK 克隆解析查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆