From d226f4da4c213970dd7298c4ed47783efa2eecc0 Mon Sep 17 00:00:00 2001 From: Bryan Nelson <1914742+bryanjnelson@users.noreply.github.com> Date: Wed, 22 May 2024 12:51:02 -0400 Subject: [PATCH] [EdgeDB] Add Pins Seeding (#3212) --- dbschema/seeds/019.pins.edgeql | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 dbschema/seeds/019.pins.edgeql diff --git a/dbschema/seeds/019.pins.edgeql b/dbschema/seeds/019.pins.edgeql new file mode 100644 index 0000000000..7c31e6c45a --- /dev/null +++ b/dbschema/seeds/019.pins.edgeql @@ -0,0 +1,53 @@ +with + usersJson := to_json('[ + { + "name": "Bilbo", + "pinnables": [ + "Sindarin", + "Quenya", + "Dwarvish/Elvish Alliance", + "Fellowship of Halfing Languages", + "Emyn Muil", + "Arnor Lake", + "South Downs" + ] + }, + { + "name": "Peregrin", + "pinnables": [ + "English", + "Sindarin", + "Eriador Church", + "The Rivendell Partnership", + "Misty Mountains", + "Lothlorien" + ] + }, + { + "name": "Aragorn", + "pinnables": [ + "Sindarin", + "Eriador Church", + "The Rivendell Partnership", + "Emyn Muil", + "Misty Mountains", + "Lothlorien" + ] + } + ]'), + users := distinct ( + for user in json_array_unpack(usersJson) + union ( + update User + filter .realFirstName = user['name'] + set { + pins += ( + select Mixin::Pinnable + filter [is Mixin::Named].name = json_array_unpack(user['pinnables']) + ) + } + ) + ), + modified := (select users filter .modifiedAt = datetime_of_statement()) +select {`Modified Users` := modified.realFirstName ++ ' ' ++ modified.realLastName} +filter count(modified) > 0;