We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8e33914 + abdb22c commit 06f95baCopy full SHA for 06f95ba
src/utils/data/questions/get.ts
@@ -18,7 +18,7 @@ export const getQuestion = async (
18
}
19
20
try {
21
- const res = await prisma.questions.findUnique({
+ let res = await prisma.questions.findUnique({
22
where: identifier === 'uid' ? { uid: value } : { slug: value },
23
include: {
24
answers: true,
@@ -31,6 +31,22 @@ export const getQuestion = async (
31
},
32
});
33
34
+ // If not found, try the other identifier
35
+ if (!res) {
36
+ res = await prisma.questions.findUnique({
37
+ where: identifier === 'uid' ? { slug: value } : { uid: value },
38
+ include: {
39
+ answers: true,
40
+ tags: {
41
42
+ tag: true,
43
+ },
44
45
+ QuestionResources: true,
46
47
+ });
48
+ }
49
+
50
if (!res) {
51
console.error('Question not found');
52
return null;
0 commit comments