All documents in the mgoactor collection have at least the following fields:
_id | the mongo id | ||
actor | int | the id number given by sakila | |
first_name | String | first name (all caps) | |
last_name | String | last name (all caps) | |
films | array | an array of embedded documents each of which has the following fields | |
categ | integer | ||
catname | string | ||
filmid | integer | ||
filmname | string |
All documents in the mgofilm collection have at least the following fields:
_id | the mongo id | |
film_id | int | the sakila id |
title | String | film title |
cat_id | int | the sakila category id |
cat_name | String | the category name |
description | String | description |
release_year | int | year |
language_id | int | sakila language id |
language | String | the name of the language |
rental_rate | Double | price to rent |
length | int | minutes |
actors | array | an array of embedded documents each of which has teh following fields: aid: -- integer, first_name, last_name |
command | explanation | Sample usage |
---|---|---|
$lt | < | db.mgoactor.findOne({actor:{$lt:5}}) |
$lte | <= | db.mgoactor.findOne({actor:{$lt:5}}) |
$gt | > | db.mgoactor.find({actor:{$gt:198}}) |
$gte | >= | db.mgoactor.find({"films.filmid":{"$gte":1990}}) |
$ne | ≠ | db.mgoactor.find({"actor":{$ne:"BOB"}}, {"films.filmid":0}) |
$exists | a field exists | db.spices.find( { saffron: { $exists: true } } ) find all items in the spices collection that have the field saffron |
$in | { field: { $in: [value1, value2, ...] } } | db.mgoactor.find({"first_name":{$in:["BOB", "LUCILLE"]}}).count() |
$nin | db.mgoactor.find({"first_name":{$nin:["BOB", "LUCILLE"]}}).count() | |
$and $or | db.mgoactor.find({$or: [{first_name: "BOB"}, {first_name:"LUCILLE"}]}).count() db.mgoactor.find({$and: [{first_name: "BOB"}, {first_name:"LUCILLE"}]}).count() | |
$regex | match using a regular expression | db.mgoactor.find({ first_name: {$regex:"^D.*"}}).count() |