Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var pipeline = [
- {
- $match: {
- "imdb.rating": { $gte: 7 },
- genres: { $nin: [ "Crime", "Horror" ] } ,
- rated: { $in: ["PG", "G" ] },
- languages: { $all: [ "English", "Japanese" ] }
- }
- }
- ]
- db.movies_sample.aggregate(pipeline)
- var pipeline = [
- {
- $match: {
- "imdb.rating": { $gte: 7 },
- genres: { $nin: [ "Crime", "Horror" ] } ,
- rated: { $in: ["PG", "G" ] },
- languages: { $all: [ "English", "Japanese" ] }
- }
- },
- {
- $project: { "_id": 0, "title": 1, "rated": 1 }
- }
- ]
- var pipeline = [
- {
- $match: {
- title: {
- $type: "string"
- }
- }
- },
- {
- $project: {
- title: { $split: ["$title", " "] },
- _id: 0
- }
- },
- {
- $match: {
- title: { $size: 1 }
- }
- }
- ]
- var pipeline = [
- {
- $match: {
- cast: { $elemMatch: { $exists: true } },
- directors: { $elemMatch: { $exists: true } },
- writers: { $elemMatch: { $exists: true } }
- }
- },
- {
- $project: {
- _id: 0,
- cast: 1,
- directors: 1,
- writers: {
- $map: {
- input: "$writers",
- as: "writer",
- in: {
- $arrayElemAt: [
- { $split: ["$$writer", " ("] }, 0
- ]
- }
- }
- }
- }
- },
- {
- $project: {
- labor_of_love: {
- $gt: [ { $size: { $setIntersection: ["$cast", "$directors", "$writers"] } }, 0 ]
- }
- }
- },
- {
- $match: { labor_of_love: true }
- },
- {
- $count: "labors of love"
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment