Good afternoon,
I have recently started working with DGraph and I am very pleased! I have recently come across an obstacle with building out my Schema.
I am working with types that have a:
tags: [Tags!]!
property. I set the Tags as ENUM types and there are many of them. The problem I am coming across is that the Tags sometimes have multiple words, for example:
enum Tags {
ALCOHOL
ALCOHOLIC_BEVERAGES
NON_ALCOHOLIC
ALUMINUM_CANNING_BEVERAGES
}
When using ENUMs I understand that you can’t have spaces, so that’s why I put the underscores. However, when displaying this on the Client-side, we can not have the underscores, we need to have the actual spaces. We can make a formula that removes the underscores and replaces them with a space on the front end, but I want to know if this is the best solution.
Is there a better way to manage these tags in Dgraph? For example, should there be a Tag type that has a property named: productTitle: String! like so:
type Tag {
id: ID!
productTitle: String!
}
This way we can have the spaces be a part of the actual tags:
- alcoholic beverages
- non-alcoholic beverages
- aluminum canning beverage
That way we get better search options than we would if we used the ENUMs (anyofterms, allofterms). I understand this might take up way more memory in the database. Right now I don’t know if it would be substantially different in its memory usage.
For clarity, the product tags are how the frontend users would search and find the entities in the database. They type a product in a search bar and we would search through the database for any nodes that have that Tag in their “tags” property. Then we display a list of all the nodes that have those tags.
Do you have any tips on the best way to have these tags be a part of the Schema and database?
Should I go with ENUMs and deal with the underscores on the frontend?
OR
Should I create a type Tag{ “…”}, and have the product tags live as strings in a product title property?
Any help or tips would be greatly appreciated!