mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-24 15:27:43 +01:00
32 lines
656 B
JavaScript
Vendored
32 lines
656 B
JavaScript
Vendored
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();
|
|
}
|
|
|
|
setAttributes(attributes: { [string]: any }): void {
|
|
for (const [attribute, value] of Object.entries(attributes)) {
|
|
this[attribute] = value;
|
|
}
|
|
}
|
|
|
|
getJsonApiBaseUrl(): string {
|
|
return '/api';
|
|
}
|
|
|
|
getJsonApiType(): string {
|
|
return (super.getJsonApiType() ?? snakeCase(this.constructor.name));
|
|
}
|
|
}
|