Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
];
export class CarService {
static getInstance(): CarService {
return CarService._instance;
}
private static _instance: CarService = new CarService();
private static cloneUpdateModel(car: Car): object {
// tslint:disable-next-line:ban-comma-operator
return editableProperties.reduce((a, e) => (a[e] = car[e], a), { _id: car.id });
}
private allCars: Array = [];
private carsStore = DataStore.collection("cars");
constructor() {
if (CarService._instance) {
throw new Error("Use CarService.getInstance() instead of new.");
}
CarService._instance = this;
}
load(): Promise {
return this.login().then(() => {
return this.carsStore.sync();
}).then(() => {
const sortByNameQuery = new Query();
sortByNameQuery.ascending("name");
const stream = this.carsStore.find(sortByNameQuery);