fix(core): update

This commit is contained in:
2021-09-17 22:34:15 +02:00
parent 236c8c6551
commit aeb35705d4
4 changed files with 27 additions and 31 deletions

View File

@ -56,7 +56,8 @@ tap.test('should establish a connection to mongod', async () => {
// ------
// Collections
// ------
class CarTemplate extends smartdata.SmartDataDbDoc<CarTemplate, CarTemplate> {
@smartdata.Manager()
class Car extends smartdata.SmartDataDbDoc<Car, Car> {
@smartdata.unI()
public index: string = smartunique.shortId();
@ -79,20 +80,22 @@ class CarTemplate extends smartdata.SmartDataDbDoc<CarTemplate, CarTemplate> {
}
const createCarClass = (dbArg: smartdata.SmartdataDb) => {
console.log(this);
@smartdata.Collection(() => {
return dbArg;
})
class Car extends CarTemplate {};
smartdata.setDefaultManagerForDoc({db: dbArg}, Car);
return Car;
};
tap.test('should prodice a car', async () => {
tap.test('should produce a car', async () => {
const CarClass = createCarClass(testDb);
const carInstance = new CarClass('red', 'Mercedes');
await carInstance.save();
});
tap.test('should get a car', async () => {
const car = Car.getInstance({
color: 'red'
})
})
// =======================================
// close the database connection
// =======================================