$cart = Cart::where('user_id', $request->user_id)->push('cart', [
"uuid" => uniqid(),
"product_id" => $request->product_id,
"product_type_id" => $request->product_type_id,
"address_id" => $request->address_id,
"voucher_id" => $request->voucher_id,
"coureer_id" => $request->coureer_id,
"note" => $request->note,
"qty" => $request->qty,
"type" => $request->type,
"expired_at" => $this->addWeekFromCurrentTime(4),
"created_at" => $this->getCurrentTime()
]);使用moloquent推送数据时如何更改mongodb中的键值
当我推送时,mongodb总是生成增量密钥,如何更改它?
发布于 2017-09-16 17:58:03
您必须重写_id,因为MongoDB总是为bson生成默认ID,或者如果要禁用它,可以在不使用默认索引的情况下创建合谋。
db.createCollection("coll", { autoIndexId: false }) 这可以在mongo控制台中完成。
https://stackoverflow.com/questions/46256015
复制相似问题