-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement typedsql for raw queries
- Loading branch information
Showing
7 changed files
with
96 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["typedSql"] | ||
} | ||
|
||
datasource db { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- @param {String} $1:entryId The ID of the entry to collect relations for | ||
-- @param {String} $2:userRole The role of the current user | ||
-- @param {String} $3:userId The ID of the current user | ||
SELECT Entry.id, Value.value, Asset.icon, Asset.slug FROM Entry | ||
INNER JOIN Value value ON fieldId = (SELECT nameFieldId FROM Asset WHERE Asset.id = entry.assetId) AND entryId = Entry.id | ||
INNER JOIN Asset ON Entry.assetId = Asset.id | ||
WHERE | ||
Entry.id IN (SELECT entryId FROM Value WHERE value LIKE $1) | ||
AND | ||
deleted = false | ||
AND | ||
Entry.aclId IN (SELECT aclId FROM ACLEntry | ||
WHERE read = true AND ( | ||
(type = "role" AND target = $2) | ||
OR | ||
(type = "user" AND target = $3) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- @param {String} $1:entryId The ID of the entry to collect revisions for | ||
SELECT ValueHistory.id, ValueHistory.createdAt, ValueHistory.changeNote, Field.name as fieldName, User.name as userName FROM ValueHistory | ||
INNER JOIN Value on Value.id = ValueHistory.valueId | ||
INNER JOIN Field on Field.id = Value.fieldId | ||
INNER JOIN User on User.id = ValueHistory.editedById | ||
WHERE Value.entryId = $1 | ||
ORDER BY ValueHistory.createdAt DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- @param {String} $1:entryId The ID of the entry to collect values for | ||
SELECT Value.id, Value.value, AssetField."order", Field.type, Field.meta, Value.fieldId, Field.name as fieldName FROM Value | ||
INNER JOIN Entry ON Entry.Id = Value.entryId | ||
INNER JOIN Asset on Asset.Id = Entry.assetId | ||
INNER JOIN AssetField on AssetField.assetId = Asset.id AND AssetField.fieldId = Value.fieldId | ||
INNER JOIN Field on Field.id = Value.fieldId | ||
WHERE entryId = $1 | ||
ORDER BY AssetField."order" ASC |