added Decorator support for easy connection between classes and collections

This commit is contained in:
2016-09-14 01:02:11 +02:00
parent f7f7852b7f
commit 6683c05c22
12 changed files with 53 additions and 23 deletions

View File

@@ -18,8 +18,6 @@ interface ITestObject1 {
let testDbCollection: smartdata.DbCollection<ITestObject1>
describe('mongodb', function () {
it('should start mongodb', function (done) {
this.timeout(30000)
@@ -72,22 +70,26 @@ describe('smartdata', function () {
testDb.close()
})
it('should create an extended class', function () {
@smartdata.Collection(testDb)
class TestCar extends smartdata.DbDoc<TestCar> {
color: string
constructor(optionsArg: {
color: string,
property2: number
}) {
super('testCar',testDb)
super()
this.color = optionsArg.color
}
};
let testCarInstance = new TestCar({
color: 'red',
property2: 2
})
should(testCarInstance.collection).be.instanceof(smartdata.DbCollection)
should(testCarInstance).be.instanceof(smartdata.DbDoc)
testCarInstance.save()
it('should get a collection for testCar',function() {
})
})
})