php - masalah kemas kini di bawah data mongo
仅有的幸福
仅有的幸福 2017-06-16 09:18:33
0
1
770
数据结构如下
array:1 [▼
  "59423208bff372441400002c" => array:30 [▼
    "_id" => MongoId {#687 ▶}
    "id" => 8850
    "author_id" => 83
    "category_id" => "10"
    "title" => "更多好看的看看 v 卡口就好吧"
    "view_type" => 1
    "post_type" => 1
    "body" => ""
    "tag" => ""
    "excerpt" => ""
    "lat" => 39.9457107
    "lng" => 116.3677488
    "sp" => array:2 [▶]
    "geo_encode" => "wx4g0pbkth4tbuu5ujz0g"
    "is_original" => 0
    "thumbnail" => []
    "platform" => 1
    "status" => 1
    "province" => "北京市"
    "city" => ""
    "district" => "朝阳区"
    "address" => "西直门宾馆"
    "featured" => 0
    "easemob_chatroom_id" => "18903238508541"
    "topic_length" => 24
    "ended_at" => "2017-06-15 15:36:55"
    "deleted_at" => "2017-06-15 15:36:55"
    "created_at" => "2017-06-14 15:34:40"
    "updated_at" => "2017-06-14 15:36:55"
    "comment" => array:2 [▼
      0 => array:12 [▼
        "id" => 64
        "easemob_chatroom_id" => "18903238508541"
        "message" => "23"
        "message_type" => "txt"
        "message_ext" => ""
        "uid" => 80
        "avatar" => "201705/080105491e54R7.jpg"
        "status" => 1
        "lng" => null
        "lat" => null
        "created_at" => "2017-06-12 11:04:27"
        "updated_at" => "2017-06-15 15:07:34"
      ]
      1 => array:12 [▼
        "id" => 61
        "easemob_chatroom_id" => "18903238508541"
        "message" => "4"
        "message_type" => "txt"
        "message_ext" => ""
        "uid" => 80
        "avatar" => "201705/080105491e54R7.jpg"
        "status" => 1
        "lng" => null
        "lat" => null
        "created_at" => "2017-06-12 11:04:27"
        "updated_at" => "2017-06-15 15:07:49"
      ]
    ]
  ]
]

Soalan:

  1. Saya menggunakan $push untuk menolak ulasan[0] ke dalam data dalam mongo

  2. Atas sebab tertentu, saya tidak mahu nilai tertentu dalam ulasan Operasi manakah yang harus saya gunakan untuk memadam sebarang elemen tatasusunan (elemen tatasusunan dalam soalan ini juga tatasusunan)

  3. .
  4. Arahan kemas kini data Mongodb Saya mencuba beberapa kaedah, tetapi ia tidak berkesan.

仅有的幸福
仅有的幸福

membalas semua(1)
过去多啦不再A梦
findOneAndUpdate()
操作符为$pull
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan