Why does not the creation of indexes in the schema of mongoose?

I do not understand what is wrong, the rule adding indexes in the schema in fact is why it is not working.
Start from the beginning
Delete all indexes in the collection popsts
db.posts.dropIndexes()
The result db.posts.getIndexes()
[
{
 "v" : 2,
 "key" : {
 "_id" : 1
},
 "name" : "_id_",
 "ns" : "site.posts"
}
]


Trying to make a selection .skip(10000).limit(12).sort({indexAt: -1}) the page crashes the following message
Executor error during the find command: OperationFailed: the Sort operation used more than the maximum 33554432 bytes of RAM. Add an index or specify a smaller limit.

OK. index no, go to mongoose schema and add the following
schema.index({indexAt: 1});
Restart node and refresh the page
Executor error during the find command: OperationFailed: the Sort operation used more than the maximum 33554432 bytes of RAM. Add an index or specify a smaller limit.

Go to mongodb and check the indexes
[
{
 "v" : 2,
 "key" : {
 "_id" : 1
},
 "name" : "_id_",
 "ns" : "site.posts"
},
{
 "v" : 2,
 "unique" : true,
 "key" : {
 "url" : 1
},
 "name" : "url_1",
 "ns" : "site.posts",
 "background" : true
},
{
 "v" : 2,
 "key" : {
 "indexAt" : 1
},
 "name" : "indexAt_1",
 "ns" : "site.posts",
 "background" : true
}
]


The index was created, but the error does not sell, while in mongodb itself does not create the index
db.wallpapers.createIndex({'indexAt': 1})
And only then everything starts to work, and the structure of indices are the same. Why? Mongodb will cache indexes or what's going on? How can this be overcome? (MongoDB shell version v3.4.10)
June 10th 19 at 14:56
0 answer

Find more questions by tags MongoDBMongooseNode.js