@@ -409,6 +409,14 @@ public function getDocument(Document $collection, string $id, array $queries = [
409409 $ document ['$updatedAt ' ] = $ document ['_updatedAt ' ];
410410 unset($ document ['_updatedAt ' ]);
411411 }
412+ if (\array_key_exists ('_createdBy ' , $ document )) {
413+ $ document ['$createdBy ' ] = $ document ['_createdBy ' ];
414+ unset($ document ['_createdBy ' ]);
415+ }
416+ if (\array_key_exists ('_updatedBy ' , $ document )) {
417+ $ document ['$updatedBy ' ] = $ document ['_updatedBy ' ];
418+ unset($ document ['_updatedBy ' ]);
419+ }
412420 if (\array_key_exists ('_permissions ' , $ document )) {
413421 $ document ['$permissions ' ] = json_decode ($ document ['_permissions ' ] ?? '[] ' , true );
414422 unset($ document ['_permissions ' ]);
@@ -469,6 +477,14 @@ public function updateDocuments(Document $collection, Document $updates, array $
469477 $ attributes ['_createdAt ' ] = $ updates ->getCreatedAt ();
470478 }
471479
480+ if (!empty ($ updates ->getCreatedBy ())) {
481+ $ attributes ['_createdBy ' ] = $ updates ->getCreatedBy ();
482+ }
483+
484+ if (!empty ($ updates ->getUpdatedBy ())) {
485+ $ attributes ['_updatedBy ' ] = $ updates ->getUpdatedBy ();
486+ }
487+
472488 if ($ updates ->offsetExists ('$permissions ' )) {
473489 $ attributes ['_permissions ' ] = json_encode ($ updates ->getPermissions ());
474490 }
@@ -1054,10 +1070,12 @@ public function getAttributeWidth(Document $collection): int
10541070 * `_tenant` int => 4 bytes
10551071 * `_createdAt` datetime(3) => 7 bytes
10561072 * `_updatedAt` datetime(3) => 7 bytes
1073+ * `_createdBy` varchar(255) => 1021 (4 * 255 + 1) bytes
1074+ * `_updatedBy` varchar(255) => 1021 (4 * 255 + 1) bytes
10571075 * `_permissions` mediumtext => 20
10581076 */
10591077
1060- $ total = 1067 ;
1078+ $ total = 3109 ;
10611079
10621080 $ attributes = $ collection ->getAttributes ()['attributes ' ];
10631081
@@ -1891,7 +1909,7 @@ protected function getAttributeProjection(array $selections, string $prefix, arr
18911909 $ projections = [];
18921910 $ projections [] = "{$ this ->quote ($ prefix )}.* " ;
18931911
1894- $ internalColumns = ['_id ' , '_uid ' , '_createdAt ' , '_updatedAt ' , '_permissions ' ];
1912+ $ internalColumns = ['_id ' , '_uid ' , '_createdAt ' , '_updatedAt ' , '_permissions ' , ' _createdBy ' , ' _updatedBy ' ];
18951913 if ($ this ->sharedTables ) {
18961914 $ internalColumns [] = '_tenant ' ;
18971915 }
@@ -1950,6 +1968,8 @@ protected function getInternalKeyForAttribute(string $attribute): string
19501968 '$tenant ' => '_tenant ' ,
19511969 '$createdAt ' => '_createdAt ' ,
19521970 '$updatedAt ' => '_updatedAt ' ,
1971+ '$createdBy ' => '_createdBy ' ,
1972+ '$updatedBy ' => '_updatedBy ' ,
19531973 '$permissions ' => '_permissions ' ,
19541974 default => $ attribute
19551975 };
@@ -2044,6 +2064,8 @@ public function createDocuments(Document $collection, array $documents): array
20442064 $ attributes ['_createdAt ' ] = $ document ->getCreatedAt ();
20452065 $ attributes ['_updatedAt ' ] = $ document ->getUpdatedAt ();
20462066 $ attributes ['_permissions ' ] = \json_encode ($ document ->getPermissions ());
2067+ $ attributes ['_createdBy ' ] = $ document ->getCreatedBy ();
2068+ $ attributes ['_updatedBy ' ] = $ document ->getUpdatedBy ();
20472069
20482070 if (!empty ($ document ->getSequence ())) {
20492071 $ attributes ['_id ' ] = $ document ->getSequence ();
@@ -2158,6 +2180,8 @@ public function createOrUpdateDocuments(
21582180 $ attributes ['_uid ' ] = $ document ->getId ();
21592181 $ attributes ['_createdAt ' ] = $ document ->getCreatedAt ();
21602182 $ attributes ['_updatedAt ' ] = $ document ->getUpdatedAt ();
2183+ $ attributes ['_createdBy ' ] = $ document ->getCreatedBy ();
2184+ $ attributes ['_updatedBy ' ] = $ document ->getUpdatedBy ();
21612185 $ attributes ['_permissions ' ] = \json_encode ($ document ->getPermissions ());
21622186
21632187 if (!empty ($ document ->getSequence ())) {
0 commit comments