Dataset Viewer
Auto-converted to Parquet
Search is not available for this dataset
conversations
listlengths
2
2
[ { "from": "human", "value": "Insert a new employee with name 'Alice Smith', age 28, and role 'Developer'." }, { "from": "gpt", "value": "db.employees.insertOne({ name: \"Alice Smith\", age: 28, role: \"Developer\" })" } ]
[ { "from": "human", "value": "Add three new orders: (1) Order ID 101, total $200, (2) Order ID 102, total $350, (3) Order ID 103, total $500." }, { "from": "gpt", "value": "db.orders.insertMany([{ orderId: 101, total: 200 }, { orderId: 102, total: 350 }, { orderId: 103, total: 500 }])" } ]
[ { "from": "human", "value": "Retrieve all products from the database." }, { "from": "gpt", "value": "db.products.find({})" } ]
[ { "from": "human", "value": "Find all employees who are younger than 30." }, { "from": "gpt", "value": "db.employees.find({ age: { $lt: 30 } })" } ]
[ { "from": "human", "value": "Find employees who are younger than 30 and work as 'Developers'." }, { "from": "gpt", "value": "db.employees.find({ age: { $lt: 30 }, role: \"Developer\" })" } ]
[ { "from": "human", "value": "Find employees who are either younger than 25 or older than 50." }, { "from": "gpt", "value": "db.employees.find({ $or: [{ age: { $lt: 25 } }, { age: { $gt: 50 } }] })" } ]
[ { "from": "human", "value": "Get only the names and roles of all employees." }, { "from": "gpt", "value": "db.employees.find({}, { name: 1, role: 1, _id: 0 })" } ]
[ { "from": "human", "value": "Retrieve one random product from the database." }, { "from": "gpt", "value": "db.products.findOne({})" } ]
[ { "from": "human", "value": "Update Alice Smith's role to 'Senior Developer'." }, { "from": "gpt", "value": "db.employees.updateOne({ name: \"Alice Smith\" }, { $set: { role: \"Senior Developer\" } })" } ]
[ { "from": "human", "value": "Increase the total of all orders by 10%." }, { "from": "gpt", "value": "db.orders.updateMany({}, { $mul: { total: 1.1 } })" } ]
[ { "from": "human", "value": "Remove an order with ID 101." }, { "from": "gpt", "value": "db.orders.deleteOne({ orderId: 101 })" } ]
[ { "from": "human", "value": "Delete all orders with a total less than $300." }, { "from": "gpt", "value": "db.orders.deleteMany({ total: { $lt: 300 } })" } ]
[ { "from": "human", "value": "Count how many employees are in the database." }, { "from": "gpt", "value": "db.employees.countDocuments({})" } ]
[ { "from": "human", "value": "Get all employees sorted by age in ascending order." }, { "from": "gpt", "value": "db.employees.find({}).sort({ age: 1 })" } ]
[ { "from": "human", "value": "Retrieve only the first 3 orders." }, { "from": "gpt", "value": "db.orders.find({}).limit(3)" } ]
[ { "from": "human", "value": "Find the total number of employees per role." }, { "from": "gpt", "value": "db.employees.aggregate([{ $group: { _id: \"$role\", totalEmployees: { $sum: 1 } } }])" } ]
[ { "from": "human", "value": "Get the total revenue for all orders with a total greater than $400." }, { "from": "gpt", "value": "db.orders.aggregate([{ $match: { total: { $gt: 400 } } }, { $group: { _id: null, totalRevenue: { $sum: \"$total\" } } }])" } ]
[ { "from": "human", "value": "Find all blog posts that mention 'Python'." }, { "from": "gpt", "value": "db.blogs.find({ $text: { $search: \"Python\" } })" } ]
[ { "from": "human", "value": "Create an index on the orderId field to improve search performance." }, { "from": "gpt", "value": "db.orders.createIndex({ orderId: 1 })" } ]
[ { "from": "human", "value": "Search for an order with ID 102 efficiently." }, { "from": "gpt", "value": "db.orders.find({ orderId: 102 }).hint({ orderId: 1 })" } ]
[ { "from": "human", "value": "Find all employees with the role 'Developer'." }, { "from": "gpt", "value": "db.employees.find({ role: { $eq: \"Developer\" } })" } ]
[ { "from": "human", "value": "Find all employees who are not 'Developers'." }, { "from": "gpt", "value": "db.employees.find({ role: { $ne: \"Developer\" } })" } ]
[ { "from": "human", "value": "Find all orders with a total greater than $500." }, { "from": "gpt", "value": "db.orders.find({ total: { $gt: 500 } })" } ]
[ { "from": "human", "value": "Find all employees aged 30 or older." }, { "from": "gpt", "value": "db.employees.find({ age: { $gte: 30 } })" } ]
[ { "from": "human", "value": "Find all products with a price less than $100." }, { "from": "gpt", "value": "db.products.find({ price: { $lt: 100 } })" } ]
[ { "from": "human", "value": "Find all orders with a total of $200 or less." }, { "from": "gpt", "value": "db.orders.find({ total: { $lte: 200 } })" } ]
[ { "from": "human", "value": "Find employees with roles 'Developer' or 'Manager'." }, { "from": "gpt", "value": "db.employees.find({ role: { $in: [\"Developer\", \"Manager\"] } })" } ]
[ { "from": "human", "value": "Find employees who are not 'Developers' or 'Interns'." }, { "from": "gpt", "value": "db.employees.find({ role: { $nin: [\"Developer\", \"Intern\"] } })" } ]
[ { "from": "human", "value": "Find employees who are older than 25 and younger than 40." }, { "from": "gpt", "value": "db.employees.find({ $and: [{ age: { $gt: 25 } }, { age: { $lt: 40 } }] })" } ]
[ { "from": "human", "value": "Find employees who are either 'Developers' or 'Managers'." }, { "from": "gpt", "value": "db.employees.find({ $or: [{ role: \"Developer\" }, { role: \"Manager\" }] })" } ]
[ { "from": "human", "value": "Find employees who are not 'Developers'." }, { "from": "gpt", "value": "db.employees.find({ role: { $not: { $eq: \"Developer\" } } })" } ]
[ { "from": "human", "value": "Find employees who are neither 'Developers' nor 'Interns'." }, { "from": "gpt", "value": "db.employees.find({ $nor: [{ role: \"Developer\" }, { role: \"Intern\" }] })" } ]
[ { "from": "human", "value": "Find employees who have a 'salary' field." }, { "from": "gpt", "value": "db.employees.find({ salary: { $exists: true } })" } ]
[ { "from": "human", "value": "Find employees where the 'age' field is a number." }, { "from": "gpt", "value": "db.employees.find({ age: { $type: \"number\" } })" } ]
[ { "from": "human", "value": "Find orders where the total is greater than the discount." }, { "from": "gpt", "value": "db.orders.find({ $expr: { $gt: [\"$total\", \"$discount\"] } })" } ]
[ { "from": "human", "value": "Find employees whose age is divisible by 5." }, { "from": "gpt", "value": "db.employees.find({ age: { $mod: [5, 0] } })" } ]
[ { "from": "human", "value": "Find employees whose name starts with 'Jo'." }, { "from": "gpt", "value": "db.employees.find({ name: { $regex: \"^Jo\" } })" } ]
[ { "from": "human", "value": "Find blog posts containing the word 'MongoDB'." }, { "from": "gpt", "value": "db.blogs.find({ $text: { $search: \"MongoDB\" } })" } ]
[ { "from": "human", "value": "Find employees where the length of their name is greater than 10." }, { "from": "gpt", "value": "db.employees.find({ $where: \"this.name.length > 10\" })" } ]
[ { "from": "human", "value": "Find products that have both 'electronics' and 'gadgets' as tags." }, { "from": "gpt", "value": "db.products.find({ tags: { $all: [\"electronics\", \"gadgets\"] } })" } ]
[ { "from": "human", "value": "Find orders that have exactly 3 items." }, { "from": "gpt", "value": "db.orders.find({ items: { $size: 3 } })" } ]
[ { "from": "human", "value": "Find orders where at least one item has a quantity greater than 5." }, { "from": "gpt", "value": "db.orders.find({ items: { $elemMatch: { quantity: { $gt: 5 } } } })" } ]
[ { "from": "human", "value": "Calculate the total salary of all employees." }, { "from": "gpt", "value": "db.employees.aggregate([{ $group: { _id: null, totalSalary: { $sum: \"$salary\" } } }])" } ]
[ { "from": "human", "value": "Calculate the average age of employees." }, { "from": "gpt", "value": "db.employees.aggregate([{ $group: { _id: null, avgAge: { $avg: \"$age\" } } }])" } ]
[ { "from": "human", "value": "Find the minimum price among all products." }, { "from": "gpt", "value": "db.products.aggregate([{ $group: { _id: null, minPrice: { $min: \"$price\" } } }])" } ]
[ { "from": "human", "value": "Find the maximum total among all orders." }, { "from": "gpt", "value": "db.orders.aggregate([{ $group: { _id: null, maxTotal: { $max: \"$total\" } } }])" } ]
[ { "from": "human", "value": "Get the first order in the collection." }, { "from": "gpt", "value": "db.orders.aggregate([{ $group: { _id: null, firstOrder: { $first: \"$orderId\" } } }])" } ]
[ { "from": "human", "value": "Get the last order in the collection." }, { "from": "gpt", "value": "db.orders.aggregate([{ $group: { _id: null, lastOrder: { $last: \"$orderId\" } } }])" } ]
[ { "from": "human", "value": "Get the first 2 items from each order." }, { "from": "gpt", "value": "db.orders.aggregate([{ $project: { items: { $slice: [\"$items\", 2] } } }])" } ]
[ { "from": "human", "value": "Sort blog posts by text search score." }, { "from": "gpt", "value": "db.blogs.find({ $text: { $search: \"MongoDB\" } }, { score: { $meta: \"textScore\" } }).sort({ score: { $meta: \"textScore\" } })" } ]
[ { "from": "human", "value": "Unwind the items array in orders and calculate the total quantity of items sold." }, { "from": "gpt", "value": "db.orders.aggregate([{ $unwind: \"$items\" }, { $group: { _id: null, totalQuantity: { $sum: \"$items.quantity\" } } }])" } ]
[ { "from": "human", "value": "Join orders with products to get product details for each order." }, { "from": "gpt", "value": "db.orders.aggregate([{ $lookup: { from: \"products\", localField: \"productId\", foreignField: \"_id\", as: \"productDetails\" } }])" } ]
[ { "from": "human", "value": "Add a new field 'discountedTotal' to orders, which is 90% of the total." }, { "from": "gpt", "value": "db.orders.aggregate([{ $addFields: { discountedTotal: { $multiply: [\"$total\", 0.9] } } }])" } ]
[ { "from": "human", "value": "Get only the order ID and total for all orders." }, { "from": "gpt", "value": "db.orders.aggregate([{ $project: { orderId: 1, total: 1, _id: 0 } }])" } ]
[ { "from": "human", "value": "Find all orders with a total greater than $500." }, { "from": "gpt", "value": "db.orders.aggregate([{ $match: { total: { $gt: 500 } } }])" } ]
[ { "from": "human", "value": "Sort employees by salary in descending order." }, { "from": "gpt", "value": "db.employees.aggregate([{ $sort: { salary: -1 } }])" } ]
[ { "from": "human", "value": "Get the top 5 highest-paid employees." }, { "from": "gpt", "value": "db.employees.aggregate([{ $sort: { salary: -1 } }, { $limit: 5 }])" } ]
[ { "from": "human", "value": "Skip the first 10 orders and retrieve the next 5." }, { "from": "gpt", "value": "db.orders.aggregate([{ $skip: 10 }, { $limit: 5 }])" } ]
[ { "from": "human", "value": "Count the number of orders with a total greater than $1000." }, { "from": "gpt", "value": "db.orders.aggregate([{ $match: { total: { $gt: 1000 } } }, { $count: \"highValueOrders\" }])" } ]
[ { "from": "human", "value": "Get both the total number of orders and the average total in a single query." }, { "from": "gpt", "value": "db.orders.aggregate([{ $facet: { totalOrders: [{ $count: \"count\" }], averageTotal: [{ $group: { _id: null, avg: { $avg: \"$total\" } } }] }])" } ]
[ { "from": "human", "value": "Group employees into salary buckets: 0-50000, 50000-100000, 100000+." }, { "from": "gpt", "value": "db.employees.aggregate([{ $bucket: { groupBy: \"$salary\", boundaries: [0, 50000, 100000, Infinity], output: { count: { $sum: 1 } } } }])" } ]
[ { "from": "human", "value": "Find the hierarchy of employees and their managers." }, { "from": "gpt", "value": "db.employees.aggregate([{ $graphLookup: { from: \"employees\", startWith: \"$managerId\", connectFromField: \"managerId\", connectToField: \"_id\", as: \"hierarchy\" } }])" } ]
[ { "from": "human", "value": "Merge the results of an aggregation into a new collection." }, { "from": "gpt", "value": "db.orders.aggregate([{ $group: { _id: \"$status\", total: { $sum: \"$total\" } } }, { $merge: { into: \"orderSummaries\" } }])" } ]
[ { "from": "human", "value": "Replace the root document with the product details in orders." }, { "from": "gpt", "value": "db.orders.aggregate([{ $lookup: { from: \"products\", localField: \"productId\", foreignField: \"_id\", as: \"productDetails\" } }, { $replaceRoot: { newRoot: { $arrayElemAt: [\"$productDetails\", 0] } } }])" } ]
[ { "from": "human", "value": "Redact sensitive information from employee documents." }, { "from": "gpt", "value": "db.employees.aggregate([{ $redact: { $cond: { if: { $eq: [\"$role\", \"Manager\"] }, then: \"$$DESCEND\", else: \"$$PRUNE\" } } }])" } ]
[ { "from": "human", "value": "Write the results of an aggregation to a new collection." }, { "from": "gpt", "value": "db.orders.aggregate([{ $group: { _id: \"$status\", total: { $sum: \"$total\" } } }, { $out: \"orderSummaries\" }])" } ]
[ { "from": "human", "value": "Get statistics about all indexes in the collection." }, { "from": "gpt", "value": "db.orders.aggregate([{ $indexStats: {} }])" } ]
[ { "from": "human", "value": "Find the nearest locations to a given point." }, { "from": "gpt", "value": "db.locations.aggregate([{ $geoNear: { near: { type: \"Point\", coordinates: [ -73.9667, 40.78 ] }, distanceField: \"distance\", maxDistance: 5000 } }])" } ]
[ { "from": "human", "value": "Get 5 random employees." }, { "from": "gpt", "value": "db.employees.aggregate([{ $sample: { size: 5 } }])" } ]
[ { "from": "human", "value": "Find orders where the total is greater than the discount." }, { "from": "gpt", "value": "db.orders.find({ $expr: { $gt: [\"$total\", \"$discount\"] } })" } ]
[ { "from": "human", "value": "Find employees whose age is divisible by 5." }, { "from": "gpt", "value": "db.employees.find({ age: { $mod: [5, 0] } })" } ]
[ { "from": "human", "value": "Find employees whose name starts with 'Jo'." }, { "from": "gpt", "value": "db.employees.find({ name: { $regex: \"^Jo\" } })" } ]
[ { "from": "human", "value": "Find blog posts containing the word 'MongoDB'." }, { "from": "gpt", "value": "db.blogs.find({ $text: { $search: \"MongoDB\" } })" } ]
[ { "from": "human", "value": "Find employees where the length of their name is greater than 10." }, { "from": "gpt", "value": "db.employees.find({ $where: \"this.name.length > 10\" })" } ]
[ { "from": "human", "value": "Find products that have both 'electronics' and 'gadgets' as tags." }, { "from": "gpt", "value": "db.products.find({ tags: { $all: [\"electronics\", \"gadgets\"] } })" } ]
[ { "from": "human", "value": "Find orders that have exactly 3 items." }, { "from": "gpt", "value": "db.orders.find({ items: { $size: 3 } })" } ]
[ { "from": "human", "value": "Find orders where at least one item has a quantity greater than 5." }, { "from": "gpt", "value": "db.orders.find({ items: { $elemMatch: { quantity: { $gt: 5 } } } })" } ]
[ { "from": "human", "value": "Calculate the total salary of all employees." }, { "from": "gpt", "value": "db.employees.aggregate([{ $group: { _id: null, totalSalary: { $sum: \"$salary\" } } }])" } ]
[ { "from": "human", "value": "Calculate the average age of employees." }, { "from": "gpt", "value": "db.employees.aggregate([{ $group: { _id: null, avgAge: { $avg: \"$age\" } } }])" } ]
[ { "from": "human", "value": "Find the minimum price among all products." }, { "from": "gpt", "value": "db.products.aggregate([{ $group: { _id: null, minPrice: { $min: \"$price\" } } }])" } ]
[ { "from": "human", "value": "Find the maximum total among all orders." }, { "from": "gpt", "value": "db.orders.aggregate([{ $group: { _id: null, maxTotal: { $max: \"$total\" } } }])" } ]
[ { "from": "human", "value": "Get the first order in the collection." }, { "from": "gpt", "value": "db.orders.aggregate([{ $group: { _id: null, firstOrder: { $first: \"$orderId\" } } }])" } ]
[ { "from": "human", "value": "Get the last order in the collection." }, { "from": "gpt", "value": "db.orders.aggregate([{ $group: { _id: null, lastOrder: { $last: \"$orderId\" } } }])" } ]
[ { "from": "human", "value": "Get the first 2 items from each order." }, { "from": "gpt", "value": "db.orders.aggregate([{ $project: { items: { $slice: [\"$items\", 2] } } }])" } ]
[ { "from": "human", "value": "Sort blog posts by text search score." }, { "from": "gpt", "value": "db.blogs.find({ $text: { $search: \"MongoDB\" } }, { score: { $meta: \"textScore\" } }).sort({ score: { $meta: \"textScore\" } })" } ]
[ { "from": "human", "value": "Find all locations within a polygon." }, { "from": "gpt", "value": "db.locations.find({ location: { $geoWithin: { $geometry: { type: \"Polygon\", coordinates: [[ [0, 0], [3, 6], [6, 1], [0, 0] ]] } } } })" } ]
[ { "from": "human", "value": "Find the nearest locations to a given point." }, { "from": "gpt", "value": "db.locations.find({ location: { $near: { $geometry: { type: \"Point\", coordinates: [ -73.9667, 40.78 ] }, $maxDistance: 5000 } } })" } ]
[ { "from": "human", "value": "Find all locations that intersect with a given polygon." }, { "from": "gpt", "value": "db.locations.find({ location: { $geoIntersects: { $geometry: { type: \"Polygon\", coordinates: [[ [0, 0], [3, 6], [6, 1], [0, 0] ]] } } } })" } ]
[ { "from": "human", "value": "Find orders where the total is greater than the discount." }, { "from": "gpt", "value": "db.orders.find({ $expr: { $gt: [\"$total\", \"$discount\"] } })" } ]
[ { "from": "human", "value": "Find employees whose salary is less than their bonus." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $lt: [\"$salary\", \"$bonus\"] } })" } ]
[ { "from": "human", "value": "Find orders where the status is 'Completed'." }, { "from": "gpt", "value": "db.orders.find({ $expr: { $eq: [\"$status\", \"Completed\"] } })" } ]
[ { "from": "human", "value": "Find employees whose role is not 'Intern'." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $ne: [\"$role\", \"Intern\"] } })" } ]
[ { "from": "human", "value": "Find employees who are older than 25 and have a salary greater than $50000." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $and: [{ $gt: [\"$age\", 25] }, { $gt: [\"$salary\", 50000] }] } })" } ]
[ { "from": "human", "value": "Find employees who are either younger than 25 or older than 50." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $or: [{ $lt: [\"$age\", 25] }, { $gt: [\"$age\", 50] }] } })" } ]
[ { "from": "human", "value": "Find employees who are not 'Developers'." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $not: { $eq: [\"$role\", \"Developer\"] } } })" } ]
[ { "from": "human", "value": "Find employees whose full name matches 'John Doe'." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $eq: [{ $concat: [\"$firstName\", \" \", \"$lastName\"] }, \"John Doe\"] } })" } ]
[ { "from": "human", "value": "Find employees whose last name starts with 'Sm'." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $eq: [{ $substr: [\"$lastName\", 0, 2] }, \"Sm\"] } })" } ]
[ { "from": "human", "value": "Find employees whose role is 'developer' (case-insensitive)." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $eq: [{ $toLower: \"$role\" }, \"developer\"] } })" } ]
[ { "from": "human", "value": "Find employees whose role is 'MANAGER' (case-insensitive)." }, { "from": "gpt", "value": "db.employees.find({ $expr: { $eq: [{ $toUpper: \"$role\" }, \"MANAGER\"] } })" } ]
[ { "from": "human", "value": "Find orders where the total is greater than 10 times the discount." }, { "from": "gpt", "value": "db.orders.find({ $expr: { $gt: [\"$total\", { $multiply: [\"$discount\", 10] }] } })" } ]
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
63

Models trained or fine-tuned on skshmjn/mongodb-chat-query