是否可以将“空”对象保存在对象中以保存引用,而不必先获取完整对象?
我正在这样做:
var myObject = new MyObject();
myObject.id = "id I retrieved somewhere on my client device"
// later
var user = request.user;
user.set("key", myObject);
Run Code Online (Sandbox Code Playgroud)
但它不起作用,它说“无法创建指向未保存的 ParseObject 的指针”
我在aws上设置了一个看起来像这样的集群
- mycluster
--- shard0
----- node0 : P
----- node1 : S
----- node2 : S
--- shard1
----- node0: P
----- node1: S
----- node2: S
--- shard2
----- node0: P
----- node1: S
----- node2: S
Run Code Online (Sandbox Code Playgroud)
我想通过连接字符串URI连接到它.
我的连接字符串目前看起来像这样:
mongodb://host0:portX,...,host9:portZ/test-database?replicaSet=mycluster
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,当我尝试连接它时,我得到错误无法访问.
但是,我可以很好地连接到单个分片.
mongodb://host0:portX,...,host3:portZ/test-database?replicaSet=shard0
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么阻止我连接到整个群集?
在使用 Parser-Server 时,我们使用这种代码来初始化服务器:
var api = new ParseServer({
databaseURI: .....,
cloud: .....,
appId: .....,
..........
serverURL: process.env.SERVER_URL || 'https://myapp.herokuapp.com/parse',
publicServerURL: process.env.PARSE_PUBLIC_SERVER_URL || 'https://myapp.herokuapp.com/parse',
..........
});
Run Code Online (Sandbox Code Playgroud)
我注意到在某些情况下,线条serverURL:和publicServerURL:不需要同时存在。但这是我需要知道的,我无法通过简单的谷歌搜索找到。
两个参数serverURL和的确切函数是publicServerURL什么?
两者有什么区别?
我有一个运行类似这样的代码的云函数,我能够得到对我的查询的响应,这是一个有效的类实例,但是当我尝试使用 set 方法更新实例时,我收到了您在标题中看到的错误.
async function addToDB(apiKey) {
const query = new Parse.Query(MyClass);
query.equalTo('apiKey', apiKey);
const response = await query.find({ useMasterKey: true });
const myInstance = response[0];
myInstance.set('total', 100);
try {
await myInstance.save({ useMasterKey: true });
} catch (e) {
console.log('E', e);
}
}
Run Code Online (Sandbox Code Playgroud) 我为了演示目的编写了这个云函数。
Parse.Cloud.define('hello', function(req, res) {
res.success("hi");
});
Run Code Online (Sandbox Code Playgroud)
但它总是返回此错误消息
{
"code": 141,
"error": "res.success is not a function"
}
Run Code Online (Sandbox Code Playgroud)
怎么了?
我正在使用 nuxt 构建一个从解析服务器获取数据的客户端。在我的 index.vue 中,我向 asyncData 内的解析服务器发送请求。我在 localhost:3000 的开发服务器上。
这是我的 index.vue 文件的一部分
export default {
asyncData() {
let user = new Parse.User()
user.set('email', 'email@company.com')
user.set('username', 'sample_user')
user.set('created_at', '2018-04-04')
user.set('updated_at', '2018-04-04')
return user
.save()
.then(response => console.log(response))
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在Chrome浏览器的(顺便说一下,我正在使用 Chrome)控制台上收到此错误
POST https://api.parse.com/1/users 410
Access to XMLHttpRequest at 'https://api.parse.com/1/users' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
我尝试将 cors 作为中间件添加到 server/index.js 如下
const cors = require('cors')
app.use(cors())
Run Code Online (Sandbox Code Playgroud)
但什么都没有改变。如何克服“永远存在”的 …