Bird
Raised Fist0
Denoframework~20 mins

ORM options (Prisma, Drizzle) in Deno - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
ORM Mastery in Deno
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Prisma Client Initialization in Deno
Which code snippet correctly initializes Prisma Client in a Deno environment to connect to a PostgreSQL database?
A
import { PrismaClient } from '@prisma/client';
const prisma = PrismaClient();
B
import { PrismaClient } from 'prisma';
const prisma = new PrismaClient();
C
import PrismaClient from '@prisma/client';
const prisma = new PrismaClient();
D
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
Attempts:
2 left
💡 Hint
Remember to import PrismaClient from the correct package and instantiate it with 'new'.
❓ component_behavior
intermediate
2:00remaining
Drizzle ORM Query Behavior in Deno
Given the following Drizzle ORM query in Deno, what will be the output if the 'users' table has three entries with ids 1, 2, and 3?
Deno
const users = await db.select().from(usersTable).where(usersTable.id.gt(1));
console.log(users.length);
A3
B2
C1
D0
Attempts:
2 left
💡 Hint
The query filters users with id greater than 1.
📝 Syntax
advanced
2:00remaining
Identifying Syntax Error in Prisma Schema
Which Prisma schema snippet contains a syntax error that will prevent generating the client?
A
model User {
  id    Int    @id @default(autoincrement())
  email String unique
  name  String?
}
B
model User {
  id    Int    @id @default(autoincrement())
  email String @unique
  name  String
}
C
model User {
  id    Int    @id @default(autoincrement())
  email String @unique
  name  String?
  createdAt DateTime @default(now())
}
D
model User {
  id    Int    @id @default(autoincrement())
  email String @unique
  name  String?
}
Attempts:
2 left
💡 Hint
Check the attribute syntax for uniqueness.
🔧 Debug
advanced
2:00remaining
Debugging Drizzle ORM Insert Failure
Why does the following Drizzle ORM insert code fail to add a new user in Deno?
Deno
await db.insert(usersTable).values({ id: 1, name: 'Alice' });
AThe id field should not be provided manually if auto-incremented
BMissing await before insert call
CNo call to execute the query after insert
DThe values object keys do not match the table columns
Attempts:
2 left
💡 Hint
Consider how auto-increment fields are handled in inserts.
❓ state_output
expert
2:00remaining
Prisma Client Query Result Shape in Deno
What is the shape of the result returned by this Prisma Client query in Deno if the 'posts' table has two posts with titles 'Hello' and 'World'?
Deno
const posts = await prisma.posts.findMany({ select: { title: true } });
console.log(posts);
A[{ title: 'Hello' }, { title: 'World' }]
B[{ posts: { title: 'Hello' } }, { posts: { title: 'World' } }]
C['Hello', 'World']
D[{ title: 'Hello', content: null }, { title: 'World', content: null }]
Attempts:
2 left
💡 Hint
The select option returns objects with only the selected fields.

Practice

(1/5)
1. What is the main purpose of using an ORM like Prisma or Drizzle in a Deno project?
easy
A. To manage server configurations and deployments
B. To create user interfaces for web applications
C. To write low-level network protocols
D. To interact with databases using simple and safe code instead of raw SQL

Solution

  1. Step 1: Understand what ORM stands for

    ORM means Object-Relational Mapping, which helps connect code with databases easily.
  2. Step 2: Identify ORM's role in Deno projects

    ORMs like Prisma and Drizzle let you write code to manage database data without writing raw SQL queries.
  3. Final Answer:

    To interact with databases using simple and safe code instead of raw SQL -> Option D
  4. Quick Check:

    ORM = Simple database code [OK]
Hint: ORMs simplify database work by hiding raw SQL [OK]
Common Mistakes:
  • Confusing ORM with UI libraries
  • Thinking ORM manages server setup
  • Assuming ORM handles network protocols
2. Which of the following is the correct way to import Prisma Client in a Deno project?
easy
A. import { PrismaClient } from "@prisma/client";
B. import PrismaClient from "prisma/client";
C. const PrismaClient = require("@prisma/client");
D. import prisma from "deno-prisma";

Solution

  1. Step 1: Recall Prisma Client import syntax

    Prisma Client is imported using ES module syntax with curly braces from "@prisma/client".
  2. Step 2: Check each option for correctness

    import { PrismaClient } from "@prisma/client"; uses correct ES import syntax. import PrismaClient from "prisma/client"; misses curly braces. const PrismaClient = require("@prisma/client"); uses CommonJS require which is not used in Deno. import prisma from "deno-prisma"; uses a wrong package name.
  3. Final Answer:

    import { PrismaClient } from "@prisma/client"; -> Option A
  4. Quick Check:

    Prisma import uses curly braces and correct package [OK]
Hint: Prisma uses named import from "@prisma/client" [OK]
Common Mistakes:
  • Using require() instead of import
  • Missing curly braces in import
  • Wrong package names
3. Given this Drizzle code snippet in Deno, what will be the output if the database has two users named 'Alice' and 'Bob'?
const users = await db.select().from(usersTable);
console.log(users.map(u => u.name));
medium
A. [{name: "Alice"}, {name: "Bob"}]
B. undefined
C. ["Alice", "Bob"]
D. SyntaxError

Solution

  1. Step 1: Understand the select query

    The code selects all rows from usersTable and stores them in users array.
  2. Step 2: Map user objects to their names

    users.map(u => u.name) creates a new array with only the name values from each user object.
  3. Final Answer:

    ["Alice", "Bob"] -> Option C
  4. Quick Check:

    Mapping user objects to names returns array of names [OK]
Hint: Mapping extracts just the names from user objects [OK]
Common Mistakes:
  • Expecting full objects instead of names array
  • Confusing map output with original array
  • Assuming syntax error due to async
4. You wrote this Prisma query in Deno but get an error: const users = await prisma.user.findMany(). What is the likely cause?
medium
A. You must import Drizzle instead of Prisma
B. You forgot to instantiate PrismaClient before using it
C. You need to use raw SQL instead of Prisma queries
D. The findMany method does not exist in Prisma

Solution

  1. Step 1: Check PrismaClient usage

    Before calling prisma.user.findMany(), you must create an instance: const prisma = new PrismaClient();
  2. Step 2: Understand error cause

    If prisma is not instantiated, calling findMany() causes an error because prisma is undefined.
  3. Final Answer:

    You forgot to instantiate PrismaClient before using it -> Option B
  4. Quick Check:

    Instantiate PrismaClient before queries [OK]
Hint: Always create PrismaClient instance before queries [OK]
Common Mistakes:
  • Assuming findMany doesn't exist
  • Trying raw SQL instead of ORM methods
  • Mixing Prisma and Drizzle imports
5. You want to use Drizzle ORM in Deno to insert a new user only if the username is not empty and then fetch all users. Which code snippet correctly applies this logic?
hard
A. if (username) { await db.insert(usersTable).values({ name: username }); } const allUsers = await db.select().from(usersTable);
B. await db.insert(usersTable).values({ name: username }); if (username) { const allUsers = await db.select().from(usersTable); }
C. const allUsers = await db.select().from(usersTable); if (username) { await db.insert(usersTable).values({ name: username }); }
D. await db.insert(usersTable).values({ name: username }); const allUsers = await db.select().from(usersTable);

Solution

  1. Step 1: Check condition before insert

    We must insert only if username is not empty, so the insert is inside the if (username) block.
  2. Step 2: Fetch all users after conditional insert

    After the conditional insert, we fetch all users with db.select().from(usersTable) and store in allUsers.
  3. Final Answer:

    if (username) { await db.insert(usersTable).values({ name: username }); } const allUsers = await db.select().from(usersTable); -> Option A
  4. Quick Check:

    Insert only if username, then fetch all users [OK]
Hint: Put insert inside if, then select all users [OK]
Common Mistakes:
  • Inserting without checking username
  • Fetching users before insert
  • Fetching users inside the if block
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard