update tests
This commit is contained in:
parent
c74873d02c
commit
14042151ba
2
dist/smartdata.classes.dbdoc.js
vendored
2
dist/smartdata.classes.dbdoc.js
vendored
@ -58,4 +58,4 @@ class DbDoc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.DbDoc = DbDoc;
|
exports.DbDoc = DbDoc;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkYXRhLmNsYXNzZXMuZGJkb2MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGRhdGEuY2xhc3Nlcy5kYmRvYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVBLDZCQUErQjtBQU8vQjs7R0FFRztBQUNIO0lBQ0UsTUFBTSxDQUFDLENBQUMsTUFBa0IsRUFBRSxHQUFXO1FBQ3JDLE9BQU8sQ0FBQyxHQUFHLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDekIsRUFBRSxDQUFDLENBQUMsQ0FBQyxNQUFNLENBQUMsa0JBQWtCLENBQUMsQ0FBQyxDQUFDO1lBQUMsTUFBTSxDQUFDLGtCQUFrQixHQUFHLEVBQUUsQ0FBQTtRQUFDLENBQUM7UUFDbEUsTUFBTSxDQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQTtJQUNyQyxDQUFDLENBQUE7QUFDSCxDQUFDO0FBTkQsb0JBTUM7QUFFRDtJQXNCRTs7T0FFRztJQUNIO1FBQ0UsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFBO1FBQ3BDLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxDQUFDLFdBQVcsQ0FBRSxjQUFjLENBQUUsQ0FBQTtJQUN0RCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0gsSUFBSTtRQUNGLElBQUksY0FBYyxHQUFRLEVBQ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json
12
package.json
@ -19,18 +19,18 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartdata#README",
|
"homepage": "https://gitlab.com/pushrocks/smartdata#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/lodash": "^4.14.69",
|
"@types/lodash": "^4.14.74",
|
||||||
"@types/mongodb": "^2.2.7",
|
"@types/mongodb": "^2.2.11",
|
||||||
"beautylog": "^6.1.10",
|
"beautylog": "^6.1.10",
|
||||||
"lik": "^1.0.38",
|
"lik": "^1.0.40",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"mongodb": "^2.2.30",
|
"mongodb": "^2.2.31",
|
||||||
"runtime-type-checks": "0.0.4",
|
"runtime-type-checks": "0.0.4",
|
||||||
"smartq": "^1.1.6",
|
"smartq": "^1.1.6",
|
||||||
"typings-global": "^1.0.19"
|
"typings-global": "^1.0.20"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/shelljs": "^0.7.2",
|
"@types/shelljs": "^0.7.4",
|
||||||
"qenv": "^1.1.7",
|
"qenv": "^1.1.7",
|
||||||
"shelljs": "^0.7.8",
|
"shelljs": "^0.7.8",
|
||||||
"smartstring": "^2.0.24",
|
"smartstring": "^2.0.24",
|
||||||
|
@ -5,13 +5,13 @@ import { Qenv } from 'qenv'
|
|||||||
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit/')
|
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit/')
|
||||||
|
|
||||||
// the tested module
|
// the tested module
|
||||||
import * as smartdata from '../dist/index'
|
import * as smartdata from '../ts/index'
|
||||||
|
|
||||||
let mongoChildProcess
|
let mongoChildProcess
|
||||||
let testDb: smartdata.Db
|
let testDb: smartdata.Db
|
||||||
|
|
||||||
tap.test('should establish a connection to mongodb', async () => {
|
tap.test('should establish a connection to mongodb', async () => {
|
||||||
testDb = new smartdata.Db(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@sandbox-shard-00-00-uyw7y.mongodb.net:27017,sandbox-shard-00-01-uyw7y.mongodb.net:27017,sandbox-shard-00-02-uyw7y.mongodb.net:27017/${process.env.MONGO_DATABASE}?ssl=true&replicaSet=sandbox-shard-0&authSource=admin`)
|
testDb = new smartdata.Db(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@sandbox-shard-00-00-uyw7y.mongodb.net:27017,sandbox-shard-00-01-uyw7y.mongodb.net:27017,sandbox-shard-00-02-uyw7y.mongodb.net:27017/${process.env.MONGO_DATABASE}?ssl=true&replicaSet=sandbox-shard-0&authSource=admin`)
|
||||||
await testDb.connect()
|
await testDb.connect()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import { Qenv } from 'qenv'
|
|||||||
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit/')
|
let testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit/')
|
||||||
|
|
||||||
// the tested module
|
// the tested module
|
||||||
import * as smartdata from '../dist/index'
|
import * as smartdata from '../ts/index'
|
||||||
|
|
||||||
let mongoChildProcess
|
let mongoChildProcess
|
||||||
let testDb: smartdata.Db
|
let testDb: smartdata.Db
|
||||||
|
@ -52,7 +52,7 @@ export class DbDoc<T> {
|
|||||||
* saves this instance but not any connected items
|
* saves this instance but not any connected items
|
||||||
* may lead to data inconsistencies, but is faster
|
* may lead to data inconsistencies, but is faster
|
||||||
*/
|
*/
|
||||||
save() {
|
save () {
|
||||||
let saveableObject: any = {} // is not exposed to outside, so any is ok here
|
let saveableObject: any = {} // is not exposed to outside, so any is ok here
|
||||||
for (let propertyNameString of this.saveableProperties) {
|
for (let propertyNameString of this.saveableProperties) {
|
||||||
saveableObject[ propertyNameString ] = this[ propertyNameString ]
|
saveableObject[ propertyNameString ] = this[ propertyNameString ]
|
||||||
@ -70,14 +70,14 @@ export class DbDoc<T> {
|
|||||||
* also store any referenced objects to DB
|
* also store any referenced objects to DB
|
||||||
* better for data consistency
|
* better for data consistency
|
||||||
*/
|
*/
|
||||||
saveDeep(savedMapArg: Objectmap<DbDoc<any>> = null) {
|
saveDeep (savedMapArg: Objectmap<DbDoc<any>> = null) {
|
||||||
if (!savedMapArg) {
|
if (!savedMapArg) {
|
||||||
savedMapArg = new Objectmap<DbDoc<any>>()
|
savedMapArg = new Objectmap<DbDoc<any>>()
|
||||||
}
|
}
|
||||||
savedMapArg.add(this)
|
savedMapArg.add(this)
|
||||||
this.save()
|
this.save()
|
||||||
for (let propertyKey in this) {
|
for (let propertyKey in this) {
|
||||||
let property = this[ propertyKey ]
|
let property: any = this[ propertyKey ]
|
||||||
if (property instanceof DbDoc && !savedMapArg.checkForObject(property)) {
|
if (property instanceof DbDoc && !savedMapArg.checkForObject(property)) {
|
||||||
property.saveDeep(savedMapArg)
|
property.saveDeep(savedMapArg)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user