Skip to content

Instantly share code, notes, and snippets.

@shadow1349
Created September 16, 2019 20:09
Show Gist options
  • Save shadow1349/65ed90edc7eead31238bf4f788f4fe32 to your computer and use it in GitHub Desktop.
Save shadow1349/65ed90edc7eead31238bf4f788f4fe32 to your computer and use it in GitHub Desktop.
export interface IModel {
Id: string;
CreatedOn: number;
}
export interface IAlgoliaModel {
objectID: string;
_tags?: string[];
}
export class Model implements IModel, IAlgoliaModel {
Id: string;
objectID: string;
CreatedOn: number;
_tags?: string[];
constructor(model: IModel) {
this.Id = model.Id;
this.objectID = model.Id;
this.CreatedOn = model.CreatedOn;
}
toJSON() {
const obj = Object.assign({}, this) as Object;
return { ...obj };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment