Start a new topic

What is the _id validation convention in Kinvey?

I'm using my own _ids for records and notice that some values do not work and get replaced with a default, internally set value.



spud-SP973_1 (does not work, gets replaced with an internal)

spud_SP973_1 (does not work, gets replaced with an internal)



spud-SP973_12 (works)

spud-SP973_ (works)

SP973_1 (works)



Is there a rule I can incorporate in my naming convention?

Hi Daniel, this is due to a property of BSON ObjectIDs (which our backing database uses). The server will try to cast any incoming _id string to an objectID, and if successful, use the converted value. ObjectIDs can be created from 12 or 24 character strings, which is the reason the 12-characters _id strings you included are not working as you expect.



We are planning to migrate away from using ObjectIDs in the future, but until then, I recommend that if you require your own IDs, use strings of lengths other than 12 or 24 characters.
Ah 12 characters, nothing to do with - or _ . Thanks, I'll take that into account.
Login or Signup to post a comment