Enforce one field based on another - kebab-case example

I was just curious if anyone had any ideas on how to enforce one field based on another.

Let’s say I had:

title = “Make money on dgraph”
title-kebab = “make-money-on-dgraph”

Is there anyway to enforce, or generate on the backend, that the title-kebab field is a correct version of the title field?

Thanks,
J

This is tagged with Dgraph. Are you using GraphQL or DQL? With DQL, the answer is no, not on the database side. With GraphQL it is possible using a lambda field resolver

Slash Dgraph (GraphQL)…

So in that case as @verneleem said you can use lambda resolver to run javascript before the data is commited to the db and edit it so it will always contain - instead of space

1 Like