From 6448516aa05d9cbcba01d09ec469105eb691ff70 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 11 Sep 2019 11:56:41 +0200 Subject: [PATCH] fix(core): update --- test/test.ts | 32 ++++++++++++++++++++++++++++++++ ts/smartdata.classes.doc.ts | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/test/test.ts b/test/test.ts index 0f648cc..990641f 100644 --- a/test/test.ts +++ b/test/test.ts @@ -109,6 +109,38 @@ tap.test('should be able to delete an instance of car', async () => { expect(myCar2.color).to.equal('red'); }); + + +// tslint:disable-next-line: max-classes-per-file +@smartdata.Collection(() => { + return testDb; +}) +class Truck extends smartdata.SmartDataDbDoc { + @smartdata.unI() + public id: string = smartunique.shortId(); + + @smartdata.svDb() + public color: string; + + @smartdata.svDb() + public brand: string; + + constructor(colorArg: string, brandArg: string) { + super(); + this.color = colorArg; + this.brand = brandArg; + } +} + +tap.test('should store a new Truck', async () => { + const truck = new Truck('blue', 'MAN'); + await truck.save(); + const myTruck = await Truck.getInstance({color: 'blue'}); + console.log(myTruck); + +}); + + // ======================================= // close the database connection // ======================================= diff --git a/ts/smartdata.classes.doc.ts b/ts/smartdata.classes.doc.ts index a71faae..7f855ad 100644 --- a/ts/smartdata.classes.doc.ts +++ b/ts/smartdata.classes.doc.ts @@ -113,7 +113,7 @@ export class SmartDataDbDoc { return returnArray; } - static async getInstance(filterArg): Promise { + public static async getInstance(filterArg): Promise { const result = await this.getInstances(filterArg); if (result && result.length > 0) { return result[0];