@@ -238,6 +238,8 @@ public function createCollection(string $name, array $attributes = [], array $in
238238 " . $ sqlTenant . "
239239 \"_createdAt \" TIMESTAMP(3) DEFAULT NULL,
240240 \"_updatedAt \" TIMESTAMP(3) DEFAULT NULL,
241+ \"_createdBy \" VARCHAR(255) DEFAULT NULL,
242+ \"_updatedBy \" VARCHAR(255) DEFAULT NULL,
241243 _permissions TEXT DEFAULT NULL,
242244 " . \implode (' ' , $ attributeStrings ) . "
243245 PRIMARY KEY (_id)
@@ -963,6 +965,8 @@ public function createDocument(Document $collection, Document $document): Docume
963965 $ attributes = $ document ->getAttributes ();
964966 $ attributes ['_createdAt ' ] = $ document ->getCreatedAt ();
965967 $ attributes ['_updatedAt ' ] = $ document ->getUpdatedAt ();
968+ $ attributes ['_createdBy ' ] = $ document ->getCreatedBy ();
969+ $ attributes ['_updatedBy ' ] = $ document ->getUpdatedBy ();
966970 $ attributes ['_permissions ' ] = \json_encode ($ document ->getPermissions ());
967971
968972 if ($ this ->sharedTables ) {
@@ -1077,6 +1081,8 @@ public function updateDocument(Document $collection, string $id, Document $docum
10771081 $ attributes = $ document ->getAttributes ();
10781082 $ attributes ['_createdAt ' ] = $ document ->getCreatedAt ();
10791083 $ attributes ['_updatedAt ' ] = $ document ->getUpdatedAt ();
1084+ $ attributes ['_createdBy ' ] = $ document ->getCreatedBy ();
1085+ $ attributes ['_updatedBy ' ] = $ document ->getUpdatedBy ();
10801086 $ attributes ['_permissions ' ] = json_encode ($ document ->getPermissions ());
10811087
10821088 $ name = $ this ->filter ($ collection );
@@ -1345,12 +1351,13 @@ protected function getUpsertStatement(
13451351 * @param string $attribute
13461352 * @param int|float $value
13471353 * @param string $updatedAt
1354+ * @param string|null $updatedBy
13481355 * @param int|float|null $min
13491356 * @param int|float|null $max
13501357 * @return bool
13511358 * @throws DatabaseException
13521359 */
1353- public function increaseDocumentAttribute (string $ collection , string $ id , string $ attribute , int |float $ value , string $ updatedAt , int |float |null $ min = null , int |float |null $ max = null ): bool
1360+ public function increaseDocumentAttribute (string $ collection , string $ id , string $ attribute , int |float $ value , string $ updatedAt , ? string $ updatedBy , int |float |null $ min = null , int |float |null $ max = null ): bool
13541361 {
13551362 $ name = $ this ->filter ($ collection );
13561363 $ attribute = $ this ->filter ($ attribute );
@@ -1362,7 +1369,8 @@ public function increaseDocumentAttribute(string $collection, string $id, string
13621369 UPDATE {$ this ->getSQLTable ($ name )}
13631370 SET
13641371 \"{$ attribute }\" = \"{$ attribute }\" + :val,
1365- \"_updatedAt \" = :updatedAt
1372+ \"_updatedAt \" = :updatedAt,
1373+ \"_updatedBy \" = :updatedBy
13661374 WHERE _uid = :_uid
13671375 {$ this ->getTenantQuery ($ collection )}
13681376 " ;
@@ -1375,6 +1383,7 @@ public function increaseDocumentAttribute(string $collection, string $id, string
13751383 $ stmt ->bindValue (':_uid ' , $ id );
13761384 $ stmt ->bindValue (':val ' , $ value );
13771385 $ stmt ->bindValue (':updatedAt ' , $ updatedAt );
1386+ $ stmt ->bindValue (':updatedBy ' , $ updatedBy );
13781387
13791388 if ($ this ->sharedTables ) {
13801389 $ stmt ->bindValue (':_tenant ' , $ this ->tenant );
@@ -1617,6 +1626,14 @@ public function find(Document $collection, array $queries = [], ?int $limit = 25
16171626 $ results [$ index ]['$updatedAt ' ] = $ document ['_updatedAt ' ];
16181627 unset($ results [$ index ]['_updatedAt ' ]);
16191628 }
1629+ if (\array_key_exists ('_createdBy ' , $ document )) {
1630+ $ results [$ index ]['$createdBy ' ] = $ document ['_createdBy ' ];
1631+ unset($ results [$ index ]['_createdBy ' ]);
1632+ }
1633+ if (\array_key_exists ('_updatedBy ' , $ document )) {
1634+ $ results [$ index ]['$updatedBy ' ] = $ document ['_updatedBy ' ];
1635+ unset($ results [$ index ]['_updatedBy ' ]);
1636+ }
16201637 if (\array_key_exists ('_permissions ' , $ document )) {
16211638 $ results [$ index ]['$permissions ' ] = \json_decode ($ document ['_permissions ' ] ?? '[] ' , true );
16221639 unset($ results [$ index ]['_permissions ' ]);
0 commit comments