Skip to content

Instantly share code, notes, and snippets.

@fireflysemantics
Created January 21, 2020 23:07
Show Gist options
  • Save fireflysemantics/14594af479add117cb4971e902474939 to your computer and use it in GitHub Desktop.
Save fireflysemantics/14594af479add117cb4971e902474939 to your computer and use it in GitHub Desktop.
/*
* Class mapped to the the contacts table in db.ts by the line:
* db.contacts.mapToClass(Contact)
*/
export class Contact {
id: string;
firstName: string;
lastName: string;
emails: IEmailAddress[];
phones: IPhoneNumber[];
constructor(first: string, last: string, id?:string) {
this.firstName = first;
this.lastName = last;
if (id) this.id = id;
// Define navigation properties.
// Making them non-enumerable will prevent them from being handled by indexedDB
// when doing put() or add().
Object.defineProperties(this, {
emails: { value: [], enumerable: false, writable: true },
phones: { value: [], enumerable: false, writable: true }
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment