fix: Model dates

This commit is contained in:
Maicol Battistini 2023-06-15 15:21:29 +02:00
parent b25781a026
commit 1e30ba1527
No known key found for this signature in database
1 changed files with 6 additions and 1 deletions

View File

@ -26,7 +26,7 @@ export default abstract class Model<A extends ModelAttributes, R extends ModelRe
protected static jsonApiBaseUrl = '/api/restify'; protected static jsonApiBaseUrl = '/api/restify';
protected static httpClient = new RequestHttpClient(); protected static httpClient = new RequestHttpClient();
static dates = { static dates: Record<string, string> = {
createdAt: 'YYYY-MM-DDTHH:mm:ss.ssssssZ', createdAt: 'YYYY-MM-DDTHH:mm:ss.ssssssZ',
updatedAt: 'YYYY-MM-DDTHH:mm:ss.ssssssZ' updatedAt: 'YYYY-MM-DDTHH:mm:ss.ssssssZ'
}; };
@ -62,6 +62,11 @@ export default abstract class Model<A extends ModelAttributes, R extends ModelRe
return super.getAttribute(attributeName as string) as ValueOf<A, AN>; return super.getAttribute(attributeName as string) as ValueOf<A, AN>;
} }
isDateAttribute(attributeName: string) {
// @ts-ignore
return super.isDateAttribute(attributeName) && this.attributes.get(attributeName) !== null;
}
getAttributes() { getAttributes() {
return super.getAttributes() as ModelAttributes; return super.getAttributes() as ModelAttributes;
} }