简体   繁体   English

将文本数组存储到Parse数据库中

[英]Storing arrays of text into Parse database

I am creating a mail system where user A sends a piece of text to user B, user B stores the text in an array in a column called Inbox (which has the attribute array). 我正在创建一个邮件系统,其中用户A向用户B发送一条文本,用户B将文本存储在名为“收件箱”(具有属性数组)的列中的数组中。

I create 5 users, the first 2 users responds with "POST https://api.parse.com/1/classes/_User/fjT08jUUk8 400 (Bad Request)" 我创建了5位用户,前2位用户回复“ POST https://api.parse.com/1/classes/_User/fjT08jUUk8 400(错误请求)”

HOWEVER, the last 3 users works perfectly fine. 但是,最后3位用户的工作情况非常好。 I'm really frustrated because I just can't figure out what the problem is. 我真的很沮丧,因为我无法弄清楚问题出在哪里。 All the users are created with the same conditions. 在相同条件下创建所有用户。

I'll link the code used here: 我将链接此处使用的代码:

<textarea name="msg" id="msg" rows="10" cols="60"></textarea>
<button ng-click="sendMessage(fetched_user.id)">Send</button>

(fetched_user.id is the corresponding id for the user you're targeting, double checked it) (fetched_user.id是您要定位的用户的对应ID,请仔细检查一下)

$scope.sendMessage = function(UID) {     
    var query = new Parse.Query(Parse.User);

    query.equalTo('objectId', UID);
    query.first({
        success: function(object) {
            var text = $('#msg').val();
            object.add("Inbox", text );
            object.save();
            $scope.$apply();    
        },
        error: function(error) {
        alert("Error: " + error.code + " " + error.message);
        }

    });
}

As always I'm really greatful for any kind of answer!! 一如既往,我真的很乐意提供任何答案! Thanks in advance :) 提前致谢 :)

SOLVED!!!! 解决了!!!!

After a lot of research I found that object.save() was the problem and that it was giving me this error: Error: 206 Parse::UserCannotBeAlteredWithoutSessionError 经过大量研究,我发现问题出在object.save()上,并给了我这个错误:错误:206 Parse :: UserCannotBeAlteredWithoutSessionError

I believe that this is some kind of security measure, that not everyone can alter users as they like. 我认为这是一种安全措施,并非每个人都可以根据自己的喜好更改用户。 This has to be done from cloud code, which per say is a whole other department. 这必须通过云代码来完成,云代码可以说是整个其他部门。 So for you guys who want to get this done, get your reading into Parse Cloud Code! 因此,对于想要完成此工作的人员,请阅读Parse Cloud Code!

您可以使用request.user获取任何云函数的调用用户, request.user是指向用户的指针,应使用该指针而不是传递objectId。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM