Aggregate(pipeline)

when i try to execute this line
db.movies.aggregate(pipeline).itcount()

this is the error i am getting

“operationTime” : Timestamp(1580119400, 1),
“ok” : 0,
“errmsg” : “not authorized on movies to execute command { aggregate: “movies”, pipeline: [ { $match: {} } ], cursor: {}, lsid: { id: UUID(“521e5041-7666-4be6-a317-b6112e9e7c58”) }, $clusterTime: { clusterTime: Timestamp(1580119390, 1), signature: { hash: BinData(0, 3758DF5F8264C9610B08D38B68ED1B6F0ACC24FA), keyId: 6730992026675838977 } }, $db: “movies” }”,
“code” : 13,
“codeName” : “Unauthorized”,
“$clusterTime” : {
“clusterTime” : Timestamp(1580119400, 1),
“signature” : {
“hash” : BinData(0,“3wGZm50bK/mDt6RYUUzfmFHpB8A=”),
“keyId” : NumberLong(“6730992026675838977”)
}
}
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:580:17
assert.commandWorked@src/mongo/shell/assert.js:673:16
DB.prototype._runAggregate@src/mongo/shell/db.js:260:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1062:12
@(shell):1:1

I don’t know what happened now if i try to run the line
db.movies.aggregate(pipeline).itcount()

nothing is happening it keeps stagnant so i have to type ctrl+c to come out and again connect to cluster.

Other things are working fine when i give show collections it will show
air_airlines
air_alliances
air_routes
bronze_banking
child_reference
customers
employees
exoplanets
gold_banking
icecream_data
movies
nycFacilities
parent_reference
silver_banking
solarSystem
stocks
system.views

after that if i type db.movies.findOne()

{
“_id” : ObjectId(“573a1390f29313caabcd421c”),
“title” : “A Turn of the Century Illusionist”,
“year” : 1899,
“runtime” : 1,
“cast” : [
“Georges M�li�s”
],
“lastupdated” : “2015-08-29 00:21:21.547000000”,
“type” : “movie”,
“directors” : [
“Georges M�li�s”
],
“imdb” : {
“rating” : 6.6,
“votes” : 580,
“id” : 246
},
“countries” : [
“France”
],
“genres” : [
“Short”
],
“tomatoes” : {
“viewer” : {
“rating” : 3.8,
“numReviews” : 32
},
“lastUpdated” : ISODate(“2015-08-20T18:46:44Z”)
}
}
this is the output

The first time you ran it, you were on a different database. This course gives you read access to the aggregations database only.

It’s doing some work, you just need to wait. Your query is doing a full collection scan because you passed in no criteria.

1 Like

Thanks for clarifying my first doubt I knew that I may have ran it on a different database just needed some confirmation. Second problem i just typed the empty match instead of passing the aggregation expression or criteria that it should match that’s why its doing nothing.

:slightly_smiling_face: :+1: