Skip to content

Custom objectId before saving #99

Closed
@lsmilek1

Description

@lsmilek1

Hello,

is there a way how to set custom objectId before the object gets saved into Parse? This does not need to be for user login/sign-up, bot than later for other objects. The reason is that I am allowing user to save objects locally in the app (Realm) before they need or are synced with server, so the Id is already defined.

After login the user I tried following object:

`struct TestParseObject: ParseObject {

var objectId: String?
var createdAt: Date?
var updatedAt: Date?
var ACL: ParseACL?
var itemName: String?

}`

saving with this code:

static func testSave() { var testObject = TestParseObject() testObject.itemName = "Able" testObject.objectId = "EaGax1Mnym" testObject.save { (result) in print("save result: \(result)") } }

result is:
save result: failure(ParseSwift.ParseError(code: ParseSwift.ParseError.Code.objectNotFound, message: "Object not found."))

If I do not change objectId, the object saves successfully.

Workaround would be to add one more field and save the other Id in that separate field, but that feels like unnecessary traffic and server load. In the custom server setting I was able to set:

{ "allowCustomObjectId": true }

And I noticed through the community that above functionality should be possible. Looking into the code description I see that there might be some wrong password also:

/** Object doesn't exist, or has an incorrect password. */ case objectNotFound = 101

But the password reference is only for user object, right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions