0
0
Remixframework~10 mins

Database query optimization in Remix - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to fetch all users from the database using Remix loader.

Remix
export const loader = async () => {
  const users = await db.user.[1]();
  return { users };
};
Drag options to blanks, or click blank then click option'
Adelete
BfindFirst
CfindMany
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using findFirst fetches only one user, not all users.
Using create or delete methods are for modifying data, not fetching.
2fill in blank
medium

Complete the code to select only the 'id' and 'name' fields from users.

Remix
const users = await db.user.findMany({
  select: { [1]: true, name: true }
});
Drag options to blanks, or click blank then click option'
Aid
Bemail
Cpassword
DcreatedAt
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting email instead of id when the task asks for id.
Selecting password exposes sensitive data.
3fill in blank
hard

Fix the error in the query to filter users older than 30.

Remix
const users = await db.user.findMany({
  where: { age: { [1]: 30 } }
});
Drag options to blanks, or click blank then click option'
Agt
Blt
Cequals
Dcontains
Attempts:
3 left
💡 Hint
Common Mistakes
Using equals filters only users exactly 30 years old.
Using contains is for strings, not numbers.
4fill in blank
hard

Fill both blanks to optimize the query by selecting only active users and ordering by creation date descending.

Remix
const users = await db.user.findMany({
  where: { active: [1] },
  orderBy: { createdAt: [2] }
});
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
C"desc"
D"asc"
Attempts:
3 left
💡 Hint
Common Mistakes
Using false filters inactive users.
Ordering by "asc" shows oldest users first.
5fill in blank
hard

Fill all three blanks to create a query that selects users with email containing 'example', limits results to 5, and skips the first 10.

Remix
const users = await db.user.findMany({
  where: { email: { [1]: "example" } },
  [2]: 5,
  [3]: 10
});
Drag options to blanks, or click blank then click option'
Acontains
Btake
Cskip
Dequals
Attempts:
3 left
💡 Hint
Common Mistakes
Using equals instead of contains filters exact matches only.
Mixing up take and skip parameters.