How to delete a field in MongoDB

ask, there is only one piece of data in the users table. If I want to delete the indexes 8-11 in the middle cartList entry (array), how can I delete these field?
I"m not very good at learning mongoDB. By the way, what are the better mongoDB quick check materials ~ Thank you

Apr.07,2021

db.users.update(
   { _id: ObjectId('58c41d5d3eddd93e9ab5b078') },
   {
    $push: {
      cartList: {
         $each: [ ],
         $slice: 8
      }
    }
  }
)

buy a mongo book. Then cooperate with the information on the official website of mongo . Then in the actual use, constantly ask yourself some problems, and then find a solution.

clipboard.png

Menu