简体   繁体   English

Parse.com关系和ACL

[英]Parse.com relationships and acl

I have a "place" class and a "checkin" class, as well as the special "User" class. 我有一个“地方”类和“签到”类,以及特殊的“用户”类。 The "checkin" has a pointer to "place" and to "user". “签到”具有指向“位置”和“用户”的指针。 Simply speaking, a user can log he has visited a place. 简而言之,用户可以记录他已经访问过的地方。

The "place" class as only read permissions, and "checkin" has both read and write. “位置”类仅具有读取权限,而“签入”具有读取和写入权限。

When creating a "checkin" object, I get the error 103: This user is not allowed to perform the update operation on place. 创建“签入”对象时,出现错误103:不允许该用户就地执行更新操作。

I tried with relationships instead of pointers and still got the same problem. 我尝试使用关系而不是指针,但仍然遇到相同的问题。

I do not want the "place" object to be updatable, and I do not understand why parse is internally trying to update it. 我不希望“位置”对象是可更新的,而且我不理解为什么解析在内部尝试更新它。

Any idea of why is this happening and how could I model the data to get it to work as I expect? 是否知道为什么会发生这种情况,以及如何对数据建模以使其按预期工作?

Edit: I add the code that makes the call to create the checkin object. 编辑:我添加了使调用创建签入对象的代码。 As can be seen, place and user already exist so it is not my intent to update it. 可以看到,位置和用户已经存在,所以我不是要更新它。

let checkin = PFObject(className: "checkin")
    checkin["user"] = PFUser.currentUser()
    let place = PFObject(className: "place")
    place.objectId = shop.id
    checkin["place"] = place
    checkin.saveInBackgroundWithBlock { (saved: Bool, error: NSError?) -> Void in
        if saved && error == nil {
            success()
        } else {
            //
        }
    }

It's a little hard to diagnose without you sharing any code, as the problem might be related to what you are trying to do in code as well. 如果不共享任何代码,将很难诊断,因为问题可能也与您尝试在代码中执行的操作有关。 I cannot comment for clarification so I'll post the answer to what I suspect is happening. 我无法发表评论以澄清问题,因此我将针对我所怀疑的事情发布答案。 If this is not the case, please comment or edit your post and I would be happy to try to help further. 如果不是这种情况,请发表评论或编辑您的帖子,我们很乐意为您提供进一步的帮助。

The problem is probably not related to you using pointers... I use pointers and do not have issues like this. 问题可能与您使用指针无关...我使用指针,并且没有类似问题。

What I think is happening is that based on your permissions, it is not letting the cloud to create the proper place. 我认为正在发生的事情是,基于您的权限,这不是在让云创建适当的位置。 This is definitely true if you have also unchecked the ability to "create" a place. 如果您还取消了“创建”位置的功能,则绝对正确。 I understand the error suggests it is specifically an update, but I have had incorrect/misleading errors before as well. 我了解该错误表明它专门是一个更新,但之前我也有错误/误导性错误。 If this is the case, allow create. 如果是这种情况,请允许创建。 Or if you don't want the public to be able to create places, then make sure the current user has the proper ACL to do so or that the cloud code being run is using the master key. 或者,如果您不希望公众能够创建场所,则请确保当前用户具有适当的ACL来执行此操作,或者确保正在运行的云代码正在使用主密钥。

If none of this is what is happening in your case, and you don't want to share code, I can recommend another workaround. 如果您遇到的所有情况都不是,并且您不想共享代码,那么我建议您使用另一种解决方法。 Leave the overall class permissions for public for place to ensure that the initialization is performed correctly. 将整体类权限留给公众使用,以确保初始化正确执行。 Then, probably in a callback after saving, set the ACL to no write. 然后,可能在保存后在回调中将ACL设置为不写入。

Edit: comments below address the added code 编辑:下面的注释解决了添加的代码

I think you are trying to query for the object with shop.id . 我认为您正在尝试使用shop.id查询对象。 I'm not very familiar with iOS programming, but the query on iOS would look like this: 我对iOS编程不是很熟悉,但是在iOS上的查询如下所示:

PFQuery *query = [PFQuery queryWithClassName:@"GameScore"];
[query getObjectInBackgroundWithId:@"xWMyZ4YEGZ" block:^(PFObject *gameScore, NSError *error) {
    // Do something with the returned PFObject in the gameScore variable.
    NSLog(@"%@", gameScore);
}];
// The InBackground methods are asynchronous, so any code after this will run
// immediately.  Any code that depends on the query result should be moved
// inside the completion block above.

https://parse.com/docs/ios/guide https://parse.com/docs/ios/guide

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

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