implenting dbDoc

This commit is contained in:
2016-09-13 22:53:21 +02:00
parent eb54fbcd0d
commit df4346e0a2
16 changed files with 187 additions and 34 deletions

View File

@@ -18,12 +18,6 @@ interface ITestObject1 {
let testDbCollection: smartdata.DbCollection<ITestObject1>
class testCar {
color: string
constructor(colorArg:string) {
this.color = colorArg
}
}
describe('mongodb', function () {
@@ -32,7 +26,7 @@ describe('mongodb', function () {
mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017', { async: true, silent: true })
let doneCalled = false
mongoChildProcess.stdout.on('data', function (data) {
console.log(smartstring.indent.indentWithPrefix(data, "*** MongoDB Process *** : "))
console.log(smartstring.indent.indentWithPrefix(data, '*** MongoDB Process *** : '))
if (!doneCalled) {
if (/waiting for connections on port 27017/.test(data)) {
doneCalled = true
@@ -68,7 +62,7 @@ describe('smartdata', function () {
]).then(() => { done() })
})
it('should find a specified doc', function (done) {
testDbCollection.find({'value3': {'$exists': true}}).then((resultArray) => {
testDbCollection.find({ 'value3': { '$exists': true } }).then((resultArray) => {
console.log(resultArray)
should(resultArray[0].value3).equal('hi')
done()
@@ -77,6 +71,25 @@ describe('smartdata', function () {
it('should close the db Connection', function () {
testDb.close()
})
it('should create an extended class', function () {
class TestCar extends smartdata.DbDoc<TestCar> {
color: string
constructor(optionsArg: {
color: string,
property2: number
}) {
super('testCar',testDb)
}
};
let testCarInstance = new TestCar({
color: 'red',
property2: 2
})
should(testCarInstance).be.instanceof(smartdata.DbDoc)
testCarInstance.save()
it('should get a collection for testCar',function() {
})
})
})
describe('mongodb', function () {