Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在parse server中使用node.js查询对象_Javascript_Node.js_Parse Platform_Parse Cloud Code - Fatal编程技术网

Javascript 如何在parse server中使用node.js查询对象

Javascript 如何在parse server中使用node.js查询对象,javascript,node.js,parse-platform,parse-cloud-code,Javascript,Node.js,Parse Platform,Parse Cloud Code,我正在尝试使用节点从解析服务器请求数据。Parse的文档对我来说毫无意义。有人可以完成我的代码,这样我就可以请求名为“Items”的类中的所有对象了吗 这是解析提供的所有内容,但它对我不起作用。我也试过了,但还是没有结果。有人可以编辑我的代码以便我可以使用云代码吗?最后,我想在我的浏览器中调用函数“hello”,并查看类“Items”的所有对象。好的,所以我终于找到了答案。到目前为止,你们中的许多人都希望将解析服务器迁移到类似Heroku的地方,因为他们将在近一个月内关闭。对于那些将来面临同样挑

我正在尝试使用节点从解析服务器请求数据。Parse的文档对我来说毫无意义。有人可以完成我的代码,这样我就可以请求名为“Items”的类中的所有对象了吗


这是解析提供的所有内容,但它对我不起作用。我也试过了,但还是没有结果。有人可以编辑我的代码以便我可以使用云代码吗?最后,我想在我的浏览器中调用函数“hello”,并查看类“Items”的所有对象。

好的,所以我终于找到了答案。到目前为止,你们中的许多人都希望将解析服务器迁移到类似Heroku的地方,因为他们将在近一个月内关闭。对于那些将来面临同样挑战并迁移到Heroku的人,请记住,您的数据是以json格式存储在mlab上的。如果要保存、查看或更新数据,并且要使用node通过http或https访问这些数据,则必须使用mongodb的API(而不是解析服务器API),并将其包含在packages.json中。查看mlab,而不是将解析云代码连接到node.js。不幸的是,Parse没有提供足够的文档来说明如何正确地使用node及其API,因此请坚持使用mlab的API。

好的,所以我终于找到了答案。到目前为止,你们中的许多人都希望将解析服务器迁移到类似Heroku的地方,因为他们将在近一个月内关闭。对于那些将来面临同样挑战并迁移到Heroku的人,请记住,您的数据是以json格式存储在mlab上的。如果要保存、查看或更新数据,并且要使用node通过http或https访问这些数据,则必须使用mongodb的API(而不是解析服务器API),并将其包含在packages.json中。查看mlab,而不是将解析云代码连接到node.js。不幸的是,Parse没有提供足够的文档来说明如何正确地使用node及其API,因此请坚持使用mlab的API。

“完成我的代码”问题在这里并不太常见。你应该尽量把你的问题减少到最小的,可重复的版本。思考具体的问题,而不是广泛的请求。您的服务器是否成功运行?您在日志中看到了什么错误?main.js是否确实存在于该目录中?你能给我们更多的工作吗?谢谢@SnakeBlisken问题现在解决了。我“完成我的代码”的问题在这里不是很好。你应该尽量把你的问题减少到最小的,可重复的版本。思考具体的问题,而不是广泛的请求。您的服务器是否成功运行?您在日志中看到了什么错误?main.js是否确实存在于该目录中?你能给我们更多的工作吗?谢谢@SnakeBlisken问题现在解决了。我
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');

var databaseUri = 'mongodb://xx';

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost!');
}

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'xx',
  masterKey: process.env.MASTER_KEY || 'xx', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'https://site.herokuapp.com/parse',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  }
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var app = express();

// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('lol');
});

// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
  res.sendFile(path.join(__dirname, '/public/test.html'));
});

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);