From my cloud/main.js file I have this query:
Parse.Cloud.define('name', function (req, res) {
Parse.Cloud.useMasterKey();
var measure = Parse.Object.extend("Measurement");
var query = new Parse.Query(measure);
query.find().then((res) => console.log(res.length)) // return 48 records
});
If a I make the same query on file dataAnalysis.js that is required in the main.js. In the main.js:
var Compute = require('./dataAnalysis');
Parse.Cloud.define('name', function (req, res) {
Compute.test();
});
In the dataAnalysis.js:
var Compute = {
test: ()=>{
Parse.Cloud.useMasterKey();
var measure = Parse.Object.extend("Measurement");
var query = new Parse.Query(measure);
query.find().then((res) => console.log(res.length)) // returns 0 record
}
module.exports = Compute;
But this query return always 0 results.
I also tried to include:
var Parse = require('parse/node').Parse;
Parse.initialize('xxxxx', null, 'xxxxx');
Parse.serverURL = 'http://localhost:1337/parse';
But it's the same, always 0 results.
I'm doing something wrong?
Additional info:
"parse": "1.9.2",
"parse-server": "^2.2.25-beta.1" // Also tried 2.2.23
node version: v6.9.1
Actually I copied and pasted the full function on the dataAnalysis.js file and call it from my main.js file and it works. As the snippet here was just an extract of a more bigger function the problem is probably somewhere else.