fix(id field now properly populated): update
This commit is contained in:
parent
c1c4a29415
commit
246e3486f0
@ -136,7 +136,10 @@ tap.test('should store a new Truck', async () => {
|
|||||||
const truck = new Truck('blue', 'MAN');
|
const truck = new Truck('blue', 'MAN');
|
||||||
await truck.save();
|
await truck.save();
|
||||||
const myTruck = await Truck.getInstance<Truck>({color: 'blue'});
|
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);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ export class SmartdataCollection<T> {
|
|||||||
await this.init();
|
await this.init();
|
||||||
await this.checkDoc(dbDocArg);
|
await this.checkDoc(dbDocArg);
|
||||||
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
const identifiableObject = await dbDocArg.createIdentifiableObject();
|
||||||
this.mongoDbCollection.deleteOne(identifiableObject);
|
await this.mongoDbCollection.deleteOne(identifiableObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,11 +103,9 @@ export class SmartDataDbDoc<T> {
|
|||||||
for (const item of foundDocs) {
|
for (const item of foundDocs) {
|
||||||
const newInstance = new this();
|
const newInstance = new this();
|
||||||
newInstance.creationStatus = 'db';
|
newInstance.creationStatus = 'db';
|
||||||
for (const key in item) {
|
for (const key of Object.keys(item)) {
|
||||||
if (key !== 'id') {
|
|
||||||
newInstance[key] = item[key];
|
newInstance[key] = item[key];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
returnArray.push(newInstance);
|
returnArray.push(newInstance);
|
||||||
}
|
}
|
||||||
return returnArray;
|
return returnArray;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user