How to use variables to DEFINE SCHEMAFULL tables with shell and curl #17
koakh
started this conversation in
Tips and tricks
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
sometimes is to boring to DRY and always repeat tablename in our schemas, sometime we want to copy one table shema and tweak a little and move on, don't worry about forget to replace tablename in one FIELD by mistake, and waste time to figure it out, or just like to refactor tablename in one place only, why not, we have great tools like multi cursor, search and replace etc, but nothing like a VARIABLE
surrealdb, until that day do everything I try, even when we hack and push it a lot,
even doing stupid things, like forget that this is database, it's not, it's a lot more
$variables are powerful beats, but can't be used with DEFINE,
to solve this, one can use shell variables and move on
old way repeating a lot of table names like 15 times in this minimal example
old school way
I think you get the point
if we wanna clone it, just copy pasta and change to
TABLE_NAME="person"
and add and remove some columns
we can use same approach for other ends, just use and abuse it
Beta Was this translation helpful? Give feedback.
All reactions