Я хочу изменить информацию о пользователе в облаке, но информация в облаке не меняется
index. js
// Example express application adding the parse-server module to expose Parse
// compatible API routes.
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/meet2me',
cloud: __dirname + '/cloud/main.js',
appId: 'app',
masterKey: 'burak21', //Add your master key here. Keep it secret!
serverURL: 'http://localhost:1337/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('I dream of being a website. Please star the parse-server repo on GitHub!');
});
// 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);
Main. js
Parse.Cloud.define('changeSearchStatus', async (request) => {
//Parse.Cloud.useMasterKey();
var search_yn = request.params.search_yn == true ? '1' : '0';
var only_gold_write = request.params.only_gold_write == true ? '1' : '0';
var only_gold_call = request.params.only_gold_call == true ? '1' : '0';
var min_age = request.params.min_age;
var max_age = request.params.max_age;
var query = new Parse.Query("User");
query.equalTo("objectId", request.params.token);
var out_data = {
error:"0",
mesaj:'success'
};
query.first({ useMasterKey: true },{
success: function (user) {
console.log("USERBILGI : "+user.get("email"));
user.set("search_yn", search_yn);
user.set("only_gold_write", only_gold_write);
user.set("only_gold_call", only_gold_call);
user.set("age_lower", min_age);
user.set("age_upper", max_age);
user.save(null, { useMasterKey: true });
}, error: function (error) {
var out_data = {
error:"1",
mesaj:'Fail'
};
console.log("error HATA");
}
});
return out_data;
});
İoni c Код
async changeSearchStatus(){
console.log("gelen:"+this.rangedualKnobs+" : "+this.rangedualKnobs['lower']);
var body = {
useMasterKey: true,
token:this.apiService.getToken(),
search_yn:this.search_yn,
only_gold_write:this.only_gold_write,
only_gold_call:this.only_gold_call,
min_age:this.rangedualKnobs['lower'],
max_age:this.rangedualKnobs['upper']
};
const response = await Parse.Cloud.run("changeSearchStatus", body);
}
Вывод на консоль:
информация: Запущена облачная функция changeSearchStatus для пользователя undefined с: Input: {"useMasterKey": true, "token" : "X38ZMM2At9", "search_yn": 1, "only_gold_write": true, "only_gold_call": false, "min_age": "18", "max_age": "55"} Результат: {"error": "0", "mesaj": "success"} {"functionName": "changeSearchStatus", "params": {"useMasterKey": true, "token": "X38ZMM2At9", "search_yn": 1, "only_gold_write": true, "only_gold_call ": false," min_age ":" 18 "," max_age ":" 55 "}}
не выдает ошибку, но информация о пользователе не изменяется