1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-24 23:37:51 +01:00

32 lines
656 B
JavaScript
Raw Normal View History

2021-10-11 19:57:42 +02:00
import {
Model as BaseModel,
PluralResponse
} from 'coloquent';
import {snakeCase} from 'lodash-es';
/**
* @property {number} id
*/
export default class Model extends BaseModel {
/**
* Just an alias to the get() method
*/
static all(): Promise<PluralResponse<InstanceType<Model>>> {
return this.get();
}
2021-10-08 16:49:17 +02:00
setAttributes(attributes: { [string]: any }): void {
for (const [attribute, value] of Object.entries(attributes)) {
2021-10-11 19:57:42 +02:00
this[attribute] = value;
2021-10-08 16:49:17 +02:00
}
}
getJsonApiBaseUrl(): string {
return '/api';
2021-09-29 20:29:08 +02:00
}
getJsonApiType(): string {
return (super.getJsonApiType() ?? snakeCase(this.constructor.name));
}
}