Created
September 16, 2019 20:09
-
-
Save shadow1349/65ed90edc7eead31238bf4f788f4fe32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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