Skip to content

Option allowCustomObjectId forces all objects to have custom objectId #1402

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 with allowCustomObjectId = true. At certain database schemes it is desired that some objects have their objectId generated by server and some (mainly in other object class) would get a custom objectId.

Feature / Enhancement Description

  • Improve documentation stating clearly that if allowCustomObjectId = true the createdAt is used to decide whether the object is being created or updated. So that developers know how the create/update is handled
  • Remove code blocking to create an object where allowCustomObjectId = true fore the objectId to not be nil, for example:
    if (allowCustomObjectId && !el.id) {

Example Use Case

As an example - in my use case there is always one private User object and always one public Profile object. Having the ability to set custom objectId to Profile that is same as the related User.objectId would give a direct reference between these two objects, saving following load:

  • back-end fetch and device sync when creating account (2x save reference between User and Profile)
  • improve the client code readability as the client code always need to pass around two different objectId for one user, instead of one "device user" objectId
  • cloud code triggers have to do extra fetch of the Profile or User object to find related partner (for example to set ACL when there is only profile's objectId known)
  • extra field at both Profile or User to link them and for some scenarios also indexing

Alternatives / Workarounds

Currently used workaround is to use reference field in each linked objects, as mentioned above the User.profileId and Profile.userId, but when user A is saving a new message to user B and A knows only B's profiles objectId, the cloud code has to fetch the Profile object to be able to set ACL to the recipient User.objectId. With growing user base and larger message count this is not negligible overload

3rd Party References

Additional observations

  • As mentioned in JS discussion it force to always use a custom id and the allowCustomObjectId is a confusing name for that. I can confirm that - as a newcomer to Parse I understood that flag for a long time wrong, that I can use both, and learned the hard way the opposite. So either it should be renamed, or the SDKs updated (what I see as small change), plus added in the documentation that allowCustomObjectId will still generate objectId if it is not defined (together with mentioning that createdAt is needed when allowCustomObjectId if true.
  • Testing with ParseSwift SDK I found that it works as intended test comit, although I am not sure if JS SDK is more critical as it is used by server directly.

Unfortunately I am very bad in javaScript and would most probably do more harm than profit but with some guidance I can try. Although to run test cases I will certainly fail as I am newcomer knowing only swift and running Parse with back4app... The documentation I can cover!

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