How to delete n-th element of array in mongodb

前端 未结 4 431
死守一世寂寞
死守一世寂寞 2020-12-05 14:45

For example I have this document:

db.test.save({
  _id: 1,
  list: [
    { key: \"a\" },
    { key: \"b\" },
    { key: \"c\" },
    { key: \"d\" },
    { ke         


        
4条回答
  •  醉话见心
    2020-12-05 15:03

    No, unfortunately what you are doing is currently the best option. Have a look at this question: In mongoDb, how do you remove an array element by its index which links to a Jira for this very issue.

提交回复
热议问题