MongoDb: Difference between $push/$addtoset

后端 未结 6 693
迷失自我
迷失自我 2020-12-08 09:06

I read the documentation in the MongoDb and I used a simple proves and I only look that: Push is sorting the array but addtoSet isn\'t it.

For me visual

6条回答
  •  孤街浪徒
    2020-12-08 09:40

    $addToSet and $push does the same thing, however $push just pushes any item disregarding the duplication causing redundancy. The former pushes only unique items, no duplication.

提交回复
热议问题