Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

How do I create a map structure with prisma that holds the key value pair? #138

Open
suhailgupta03 opened this issue May 15, 2020 · 5 comments

Comments

@suhailgupta03
Copy link

suhailgupta03 commented May 15, 2020

Article Title (if relevant)
Provide the name and link to the article with the issue

Describe the content issue
A clear and concise description of what the issue with the content was
I need to create a storage schema where it resembles the following:

{
     id: "some id",
     key1: value1,
     key2: value2,
     key3: value4 
}

Here key1, key2, .. keyn are dynamic and not known beforehand. I could not find a way with Prisma to achieve this. Any help with the documentation or is this not possible at all with Prisma?

Describe the solution you'd like to see
How can this issue be resolved?
Please see the above points.
Additional context
Add any other context or screenshots about the feature request here.
The only way I can is to have an array of objects.

[
   {
     key1: value1
   },
  {
    key2: value2
  }
]

But then this is not the optimal way, since there will be a lot many entries and I will have to iterate over the complete list to find the key1 and then gets its value

@nikolasburk
Copy link
Member

Hey @suhailgupta03 👋 you should be able to model this with the Json type as documented here. Hope that helps, please let me know if you have any further questions! 🙂

@suhailgupta03
Copy link
Author

suhailgupta03 commented May 15, 2020

I just read that. It says there is a limitation of 256KB. Do not think, it will solve my purpose.

This is what I am trying to achieve. For a website, I want to create a map, where each key i.e. the token (sentence) points to an array of URLs. It will resemble the following:

{
   hostname: "https://example.com",
   map: {
     "this is my homepage": [
          "https://example.com",
          "https://example.com/1",
          "https://example.com/44"
    ],
   "about us": [
       "https://example.com",
       "https://example.com/7",
       "https://example.com/6"
    ]
   }
}

I feel this will easily exceed 256KB. Would you suggest anything? @nikolasburk

@nikolasburk
Copy link
Member

Hmm this seems tricky indeed, maybe this is a Prisma 1 limitation for this use case then 😕 Have you considered Prisma 2.0 for this, I don't think it has the same size limitation for using Json?

@suhailgupta03
Copy link
Author

From what I have read Prisma 2.0 is in the beta stage? Should I be using that on production systems? @nikolasburk

@nikolasburk
Copy link
Member

nikolasburk commented May 15, 2020

Prisma Client is very close to being production-ready and we've seen a lot of folks successfully using it in production already. One of the main reasons why we haven't officially released it yet because we're working on upgrade guides for Prisma 1 users, but Prisma Client is already very stable.

You can find more info here: http://isprisma2ready.com/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants