fix(id field now properly populated): update

This commit is contained in:
Philipp Kunz 2019-09-11 12:12:50 +02:00
parent c1c4a29415
commit 246e3486f0
3 changed files with 7 additions and 6 deletions

View File

@ -136,7 +136,10 @@ tap.test('should store a new Truck', async () => {
const truck = new Truck('blue', 'MAN');
await truck.save();
const myTruck = await Truck.getInstance<Truck>({color: 'blue'});
console.log(myTruck);
myTruck.id = 'foo';
await myTruck.save();
const myTruck2 = await Truck.getInstance<Truck>({color: 'blue'});
console.log(myTruck2);
});

View File

@ -141,7 +141,7 @@ export class SmartdataCollection<T> {
await this.init();
await this.checkDoc(dbDocArg);
const identifiableObject = await dbDocArg.createIdentifiableObject();
this.mongoDbCollection.deleteOne(identifiableObject);
await this.mongoDbCollection.deleteOne(identifiableObject);
}
/**

View File

@ -103,10 +103,8 @@ export class SmartDataDbDoc<T> {
for (const item of foundDocs) {
const newInstance = new this();
newInstance.creationStatus = 'db';
for (const key in item) {
if (key !== 'id') {
newInstance[key] = item[key];
}
for (const key of Object.keys(item)) {
newInstance[key] = item[key];
}
returnArray.push(newInstance);
}