Question about instance names. Our use case is tha...
# general
s
Question about instance names. Our use case is that we have various restaurants in our app. These restaurant instances are synched with Permit. So now permit has those resource instances. In our app, there would be situations where we would want to change the names of those Restaurants (to correct a typo etc.). But permit does not allow instance names to be changed since they are used as an unique identifier. Has anyone run into this? How do you get around it? (I can see maintaining a "display name" in my app but before I implement it, I was curious as to see if I am on the right path)
a
Hi @Suhas Kelkar, we'd be right with you It is better to ask in #permit-saas to get a faster response from the team and our @Ask Inkeep
a
Thanks for tagging me @Alon Boshi. I'll look through relevant sources and get back to you shortly.
You're correct that resource instance keys in Permit.io are immutable and serve as unique identifiers (1) . The key approach you're considering—maintaining a separate "display name" in your application—is indeed the right path. When creating resource instances, the
key
field is the permanent identifier :
Copy code
await permit.api.resource_instances.create({
  key: "react",
  resource: "repository",
  tenant: "default",
  attributes: {
    private: "false",
    owner: "Company C",
  },
}) ;
Since instance keys cannot be changed after creation, you have a couple of options: 1. ​*Use attributes for display names*​: Store the restaurant's display name as an attribute that can be updated . Resource instance attributes can be modified through the UI or API. 2. ​*Maintain display names in your app*​: Keep the immutable key in Permit for authorization checks while storing user-facing names in your application database. The first approach keeps everything centralized in Permit, while the second gives you more flexibility for UI-specific needs. Both are valid patterns depending on you
To learn more, see the sources I considered: [[1] Sync Data into your App](https://docs.permit.io/overview/sync-applications-data)
a
The AI gave a good answer, does it make sense?
s
Yes. It makes sense. I guess, I can use an id as the instance name in permit. Then ofcourse I cannot see the real name of that instance in Permit. E.g. If restaurant is named Vivel and it's unique id in our system is say 34567, then I can use 34567 as the instance name in Permit? But then in Permit UI, I cannot see what 34567 means?
o
1. Yes, display names and unique IDs shouldn’t be the same. 2. You can delete the instance and recreate with a new name along with its attributes / relationships
3. You can save the display name as an attribute on the instance 4. We’ll consider adding a builtin display name field for resource instances