55use Exception ;
66use PDO ;
77use PDOException ;
8+ use Utopia \Database \Change ;
89use Utopia \Database \Database ;
910use Utopia \Database \Document ;
1011use Utopia \Database \Exception as DatabaseException ;
@@ -1333,7 +1334,7 @@ public function updateDocument(string $collection, string $id, Document $documen
13331334 /**
13341335 * @param string $collection
13351336 * @param string $attribute
1336- * @param array<string|int, array{old: Document, new: Document} > $documents
1337+ * @param array<Change > $documents
13371338 * @return array<Document>
13381339 * @throws DatabaseException
13391340 */
@@ -1357,8 +1358,8 @@ public function createOrUpdateDocuments(
13571358 $ documentIds = [];
13581359 $ documentTenants = [];
13591360
1360- foreach ($ documents as $ document ) {
1361- $ document = $ document [ ' new ' ] ;
1361+ foreach ($ documents as $ change ) {
1362+ $ document = $ change -> getNew () ;
13621363 $ attributes = $ document ->getAttributes ();
13631364 $ attributes ['_uid ' ] = $ document ->getId ();
13641365 $ attributes ['_createdAt ' ] = $ document ->getCreatedAt ();
@@ -1455,9 +1456,9 @@ public function createOrUpdateDocuments(
14551456 $ addQueries = [];
14561457 $ addBindValues = [];
14571458
1458- foreach ($ documents as $ index => $ document ) {
1459- $ old = $ document [ ' old ' ] ;
1460- $ document = $ document [ ' new ' ] ;
1459+ foreach ($ documents as $ index => $ change ) {
1460+ $ old = $ change -> getOld () ;
1461+ $ document = $ change -> getNew () ;
14611462
14621463 $ current = [];
14631464 foreach (Database::PERMISSIONS as $ type ) {
@@ -1530,16 +1531,17 @@ public function createOrUpdateDocuments(
15301531 }
15311532
15321533 $ internalIds = $ this ->getInternalIds ($ collection , $ documentIds , $ documentTenants );
1534+
15331535 foreach ($ documents as $ document ) {
1534- if (isset ($ internalIds [$ document[ ' new ' ] ->getId ()])) {
1535- $ document[ ' new ' ][ ' $internalId '] = $ internalIds [$ document[ ' new ' ]-> getId ()];
1536+ if (isset ($ internalIds [$ document-> getNew () ->getId ()])) {
1537+ $ document-> getNew ()-> setAttribute ( ' $internalId ', $ internalIds [$ document-> getNew ()-> getId ()]) ;
15361538 }
15371539 }
15381540 } catch (PDOException $ e ) {
15391541 throw $ this ->processException ($ e );
15401542 }
15411543
1542- return \array_map (fn ($ document ) => $ document [ ' new ' ] , $ documents );
1544+ return \array_map (fn ($ change ) => $ change -> getNew () , $ documents );
15431545 }
15441546
15451547 /**
0 commit comments