首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mongodb Atlas运行查询

Mongodb Atlas运行查询
EN

Stack Overflow用户
提问于 2019-07-15 11:04:01
回答 1查看 41关注 0票数 0
代码语言:javascript
复制
db.movies.insertMany([
        {_id: 1, title: "Wonder Woman", director: "Patty Jenkins", yearReleased: 2017, leadActors: ["Gal Gadot", "Chris Pine", "Robin Wright"], lengthInMin: 141, genre: ["Action", "Adventure", "Fantasy"], MPAA: "PG-13" },
        {_id: 2, title: "Cloud Atlas", director: "Tom Tykwer", yearReleased: 2012, leadActors: ["Tom Hanks", "Halle Berry", "Hugh Grant", "Jim Broadbent", "Jim Sturgess", "Hugo Weaving"], lengthInMin: 172, genre: ["Action", "Drama", "Mystery"], MPAA: "R" },
        {_id: 3, title: "Pan's Labyrinth", director: "Guillermo del Torro", yearReleased: 2006, leadActors: ["Ivana Baquero", "Ariadna Gil", "Sergi Lopez"], lengthInMin: 118, genre: ["Drama", "Fantasy", "War", "Foreign"], MPAA: "R" },
        {_id: 4, title: "Gone With the Wind", director: "Victor Fleming", yearReleased: 1939, leadActors: ["Clark Gable", "Vivien Leigh", "Thomas Mitchell", "Olivia de Havilland", "Leslie Howard"], lengthInMin: 238, genre: ["Drama", "History", "Romance"], MPAA: "G" },
        {_id: 5, title: "Spaceballs", director: "Mel Brooks", yearReleased: 1987, leadActors: ["Mel Brooks", "John Candy", "Rick Moranis", "Bill Pullman", "Daphne Zuniga"], lengthInMin: 96, genre: ["Adventure", "Comedy", "Sci-fi"], MPAA: "PG" },
        {_id: 6, title: "Silence of the Lambs", director: "Jonathan Demme", yearReleased: 1991, leadActors: ["Jodie Foster", "Anthony Hopkins", "Anthony Heald"], lengthInMin: 118, genre: ["Crime", "Drama", "Thriller"], MPAA: "R" },
        {_id: 7, title: "American History X", director: "Tony Kaye", yearReleased: 1998, leadActors: ["Edward Norton", "Edward Furlong", "Beverly D'Angelo", "Ethan Suplee"], lengthInMin: 119, genre: ["Crime", "Drama"], MPAA: "R" },
        {_id: 8, title: "Psycho", director: "Alfred Hitchcock", yearReleased: 1960, leadActors: ["Anthony Perkins", "Vera Miles", "John Gavin", "Janet Leigh"], lengthInMin: 109, genre: ["Horror", "Mystery", "Thriller"], MPAA: "R" },
        {_id: 9, title: "The Pianist", director: "Roman Polanski", yearReleased: 2002, leadActors: ["Adrien Brody", "Emilia Fox", "Michal Zebrowski", "Ed Stoppard"], lengthInMin: 150, genre: ["Biography", "Drama", "Music"], MPAA: "R" },
        {_id: 10, title: "Gladiator", director: "Ridley Scott", yearReleased: 2000, leadActors: ["Russell Crowe", "Joaquin Phoenix", "Connie Nielsen", "Oliver Reed"], lengthInMin: 155, genre: ["Action", "Adventure", "Drama"], MPAA: "R" },
])

如何编写查询来查找播放时间超过2小时的电影?

EN

回答 1

Stack Overflow用户

发布于 2019-07-15 12:24:32

这是一种简单转换,通过将小时转换为分钟来比较小时和lengthInMin属性。

代码语言:javascript
复制
var hourToMinute = 2 * 60;
db.movies.find({
    lengthInMin: { $gt : hourToMinute }
})
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57032802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档