@@ -2,15 +2,16 @@ import { Types } from "mongoose";
22import { AtLeast } from "../types" ;
33
44export interface IBase {
5+ readonly kind : string ;
56 __v ?: number ;
67 _id : Types . ObjectId ;
7- createdAt : string ;
8- updatedAt : string ;
8+ createdAt : Date ;
9+ updatedAt : Date ;
910 createdBy : Types . ObjectId ;
1011 updatedBy : Types . ObjectId ;
1112}
1213
13- export type IBaseMinimal = AtLeast < IBase , ' createdBy' >
14+ export type IBaseMinimal = AtLeast < IBase , " createdBy" > ;
1415
1516export class Base {
1617 readonly __v : IBase [ "__v" ] ;
@@ -31,9 +32,9 @@ export class Base {
3132 this . __v = __v ;
3233 this . _id = _id || new Types . ObjectId ( ) ;
3334
34- const now = Date . now ( ) ;
35- this . createdAt = new Date ( createdAt || now ) ;
36- this . updatedAt = new Date ( updatedAt || now ) ;
35+ const now = new Date ( Date . now ( ) ) ;
36+ this . createdAt = createdAt || now ;
37+ this . updatedAt = updatedAt || now ;
3738
3839 this . createdBy = createdBy ;
3940 this . updatedBy = updatedBy || createdBy ;
@@ -43,8 +44,8 @@ export class Base {
4344 return {
4445 __v : this . __v ,
4546 _id : this . _id ,
46- createdAt : this . createdAt . toISOString ( ) ,
47- updatedAt : this . updatedAt . toISOString ( ) ,
47+ createdAt : this . createdAt ,
48+ updatedAt : this . updatedAt ,
4849 createdBy : this . createdBy ,
4950 updatedBy : this . updatedBy ,
5051 } ;
0 commit comments