我有一些使用多位置更新方法的应用程序如下:
const updates = [];
updates['/location1'] = data;
updates['/location2'] = data2;
firebase.database().ref().update(updates);
Run Code Online (Sandbox Code Playgroud)
然而,当我正在开发一个新的应用程序时,我收到以下消息:
FIREBASE WARNING: Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.
没有关于如何在任何地方执行多位置原子更新的任何实际信息,并且文档仍然使用旧方法.链接then()不是一个好主意,因为回滚会是一场噩梦.
有关新的多位置更新方法的任何线索和/或信息?
我有一个单一图像的文件上传方法可以正常工作,使用以下代码:
$file = $request->file('file');
if ($file && $file->isValid()) {
$photo['size'] = $request->file('file')->getClientSize();
$path = $request->file('file')->store($request->subdomain);
$path = explode('/', $path);
$photo['file'] = $path[1];
$photo['cover'] = 1;
$photo['gallery'] = $newGallery->id;
$photo['uploaded_by'] = $user->id;
Photo::create($photo);
}
Run Code Online (Sandbox Code Playgroud)
$file是UploadedFile这里的一个实例,该store()方法完美运行。
但是,我需要更改方法以允许上传多个文件。以下改编的代码会导致以下错误:
$photos = $request->files->all();
foreach($photos as $photo) {
foreach($photo as $p) {
if($p->isValid()) {
$path = $p->store($request->subdomain);
$path = explode('/', $path);
$newPhoto = [
'uploaded_by' => $user->id,
'file' => $path[1],
'size' => $p->getClientSize(),
'gallery' => $request->gallery,
'subdomain' => $request->subdomain,
];
Photo::create($requestData); …Run Code Online (Sandbox Code Playgroud)