Node.js MongoError: First argument to $slice must be an array, but is of type: int

Viewed 415

Here is my query

const messages = await Thread.findOne({_id: threadId}, {messages: {$slice: [10, -10]}})

This is the error:

MongoError: First argument to $slice must be an array, but is of type: int

Obviously I'm passing an array to $slice, so why am I getting this error?

0 Answers
Related