Skip to content

Allow mixed environment of server generated and custom objectId #220

Closed
@lsmilek1

Description

@lsmilek1

New Feature / Enhancement Checklist

Current Limitation

Currently it is not possible to have mixed environment of custom and server generated objectId. In the case where User and user's Profile are two different objects in the database (keeping public data only in Profile) there is a need of reference field between these two related objects (Pointer or objectId String).

This is making it complicated in certain scenarios. For example some third object, let it be Group has a list of participants [objectId] or Pointers. When the group gets deleted and the cloud code function would like to send a message to each remaining participant, it needs to fetch each Profile's data to get related User's objectId to be able to set the ACL of the "group deleted" message object only for that recipient.

Feature / Enhancement Description

With allowCustomObjectId = true allow mixed environment so that it is possible to set the same objectId for multiple objects in different classes. This allows User and Profile to have the same objectId and there will be no need to fetch additional objects to set the ACL properly as mentioned in the above scenario, reducing also the size of the objects in the database and need of additional indexes on reference field

Example Use Case

For simple test I removed the if check on saveCommand() and it works as intended, having the need of not-nil createdAt if the object should be updated.

lsmilek1@b3346df

Leaving createdAt = nil and setting custom objectId to already existing value behaves as intended:

error saving testInbox: ParseError code=137 error=A duplicate value for a field with unique values was provided

Alternatives / Workarounds

As mentioned, available workaround is adding extra fields and indexes to the objects and therefore additional load on the server at big scale. In example of User and Profile it is also easier to read that certain object belongs together

3rd Party References

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