我正在使用Laravel Jensegger's Moloquent库来使用Mongo DB。我有一个像这样的Mongo DB文档: -
{
"_id" : ObjectId("5b1e05d7987a8e0bcd018966"),
"place_id" : "5a29f3d8d4cc987f64976fc9",
"title_AR" : "Kick Axe",
"title_EN" : "Kick Axe",
"description_AR" : "",
"description_EN" : "",
"best_photo" : "https://igx.4sqi.net/img/general/250x250/65688_HR7zrFOF5fpgVEB8Nv9SBxoy2YgZm65K36-mvoHmzWg.jpg",
"city_AR" : "New York",
"city_EN" : "New York",
"state_AR" : "NY",
"state_EN" : "NY",
"country" : "US",
"postal_code_AR" : "11217",
"postal_code_EN" : "11217",
"location_AR" : "622 Degraw St, New York, NY 11217, United States",
"location_EN" : "622 Degraw St, New York, NY 11217, United States",
"latitude" : 40.6790636331833,
"longitude" : -73.9835408883314,
"loc" : {
"type" : "Point",
"coordinates" : [
-73.9835408883314,
40.6790636331833
]
},
"website" : "https://www.kickaxe.com",
"email" : "",
"contact_number_AR" : "8335425293",
"contact_number_EN" : "8335425293",
"ratings_AR" : "8.7",
"ratings_EN" : "8.7",
"no_of_comments_AR" : 8,
"no_of_comments_EN" : 8,
"categories" : "4d4b7105d754a06377d81259,5744ccdfe4b0c0459246b4b5,4d4b7105d754a06377d81259,5744ccdfe4b0c0459246b4b5,4d4b7104d754a06370d81259,4bf58dd8d48988d1f1931735,4d4b7105d754a06377d81259,4eb1d4d54b900d56c88a45fc",
"category_array" : [
"4d4b7105d754a06377d81259",
"5744ccdfe4b0c0459246b4b5",
"4d4b7105d754a06377d81259",
"5744ccdfe4b0c0459246b4b5",
"4d4b7104d754a06370d81259",
"4bf58dd8d48988d1f1931735",
"4d4b7105d754a06377d81259",
"4eb1d4d54b900d56c88a45fc"
],
"created_date" : "2018-06-11 10:47:11",
"modified_date" : "2018-06-11 10:47:11",
"photo_saved" : 0,
"tip_saved" : 0,
"updated_at" : ISODate("2018-06-11T05:17:11.000Z"),
"created_at" : ISODate("2018-06-11T05:17:11.000Z")
}
该文档没有任何名为“ complete_status ”和“ cannonical_url ”的字段。
我想在现有文档中添加这两个字段。我正在使用此代码: -
$insertUrl = MongoFourSquarePlaces::where('place_id',$place_id)
->update(
array(
'cannonical_url'=> $url,
'complete_status'=>1
));
此代码在“ created_at ”之后添加了两个字段& “ updated_at ”字段。如何在所需位置添加两个新字段,例如在“ created_at ”字段之前?