2016-01-08 70 views
0
[Details] => Array 
     (
      [0] => Array 
       (
        [Items] => Array 
         (
          [0] => Array 
           (
            [Description] => Discriptionqwe 
            [Quantity] => qwewe 
            [ItemName] => not_available 
            [CategoryName] => health 
            [ItemsId] => 568e70d66734c482495fb085 
           ) 

         ) 

        [Distance] => 56.8KM 
        [VendorId] => 5683ad876734c4e2158b4570 
        [Rating] => 0 
        [OpeningTime] => 10AM to 11PM 
        [VendorName] => bombay ji 
       ) 

     ) 

回答

0

試試這樣說:

var update = db.collection.update(
            { _id:ObjectId("id_of_record")}, 
            { $set: { "Details.$.Items.$.Description":"Discriptionqwe" } } 
          ); 

    var is_row_affected = db.runCommand({getLastError : 1});         

    if(is_row_affected['updatedExisting'] == true){ 
     result = {msg: '1', data: []}; 
    }else { 
     result = { msg: '0', data: []}; 
    } 
    return result; 
+0

感謝給你的時間 – Pankaj