0
0
Node.jsframework~10 mins

ORM concept (Sequelize, Prisma overview) in Node.js - Interactive Code Practice

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

Complete the code to import Sequelize in a Node.js project.

Node.js
const Sequelize = require('[1]');
Drag options to blanks, or click blank then click option'
ASequelize
Bsequelize
Csequelizejs
DSequelizeJS
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'Sequelize' instead of lowercase 'sequelize'
Using incorrect package names like 'sequelizejs'
2fill in blank
medium

Complete the code to initialize a Prisma client instance.

Node.js
const prisma = new [1]();
Drag options to blanks, or click blank then click option'
ASequelize
BPrisma
CClient
DPrismaClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Sequelize' instead of 'PrismaClient'
Using just 'Prisma' without 'Client'
3fill in blank
hard

Fix the error in this Sequelize model definition by completing the missing data type.

Node.js
const User = sequelize.define('User', {
  username: {
    type: Sequelize.[1],
    allowNull: false
  }
});
Drag options to blanks, or click blank then click option'
AStr
BText
CSTRING
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or incorrect data type names
Using 'Text' instead of 'STRING'
4fill in blank
hard

Fill both blanks to write a Prisma query that finds all users with age greater than 18.

Node.js
const adults = await prisma.user.findMany({
  where: {
    age: { [1]: [2] }
  }
});
Drag options to blanks, or click blank then click option'
Agt
B18
Cgte
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gte' instead of 'gt' for strictly greater than
Using a string '18' instead of number 18
5fill in blank
hard

Fill all three blanks to create a Sequelize model with a 'title' string and 'published' boolean fields.

Node.js
const Post = sequelize.define('Post', {
  title: {
    type: Sequelize.[1],
    allowNull: false
  },
  published: {
    type: Sequelize.[2],
    defaultValue: [3]
  }
});
Drag options to blanks, or click blank then click option'
ASTRING
BBOOLEAN
Cfalse
DTRUE
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase data types
Setting defaultValue to TRUE instead of false