Working with String and Number Types in MongoDB
📖 Scenario: You are managing a small bookstore's inventory database using MongoDB. Each book has a title, author, and price. You want to store this information correctly using string and number types.
🎯 Goal: Create a MongoDB collection document for a book with proper string and number types. Then add a discount rate as a number and calculate the discounted price.
📋 What You'll Learn
Create a document with fields
title and author as stringsAdd a
price field as a numberAdd a
discountRate field as a number representing a percentageCalculate the
discountedPrice by applying the discount rate to the price💡 Why This Matters
🌍 Real World
Managing product data in a database requires correct use of string and number types to store names, prices, and calculations like discounts.
💼 Career
Database developers and data engineers often work with documents that mix strings and numbers and must perform calculations and updates on stored data.
Progress0 / 4 steps