Compare commits

..

6 Commits

Author SHA1 Message Date
6eb43a4b9f 3.1.24 2020-02-08 14:01:55 +00:00
7f89cbeecd fix(core): update 2020-02-08 14:01:55 +00:00
a042a589a0 3.1.23 2019-09-11 12:36:03 +02:00
75b5f6af08 fix(core): update 2019-09-11 12:36:02 +02:00
e6a36f22ac 3.1.22 2019-09-11 12:12:51 +02:00
246e3486f0 fix(id field now properly populated): update 2019-09-11 12:12:50 +02:00
5 changed files with 628 additions and 458 deletions

1030
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartdata", "name": "@pushrocks/smartdata",
"version": "3.1.21", "version": "3.1.24",
"private": false, "private": false,
"description": "do more with data", "description": "do more with data",
"main": "dist/index.js", "main": "dist/index.js",
@ -21,27 +21,27 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartdata#README", "homepage": "https://gitlab.com/pushrocks/smartdata#README",
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.11", "@pushrocks/lik": "^3.0.17",
"@pushrocks/smartlog": "^2.0.19", "@pushrocks/smartlog": "^2.0.21",
"@pushrocks/smartpromise": "^3.0.2", "@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartstring": "^3.0.10", "@pushrocks/smartstring": "^3.0.18",
"@pushrocks/smartunique": "^3.0.1", "@pushrocks/smartunique": "^3.0.1",
"@types/lodash": "^4.14.138", "@types/lodash": "^4.14.149",
"@types/mongodb": "^3.3.1", "@types/mongodb": "^3.3.15",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"mongodb": "^3.3.2", "mongodb": "^3.5.2",
"runtime-type-checks": "0.0.4" "runtime-type-checks": "0.0.4"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.17", "@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.24", "@gitzone/tstest": "^1.0.28",
"@pushrocks/qenv": "^4.0.4", "@pushrocks/qenv": "^4.0.6",
"@pushrocks/tapbundle": "^3.0.13", "@pushrocks/tapbundle": "^3.2.0",
"@types/mongodb-memory-server": "^1.8.0", "@types/mongodb-memory-server": "^2.3.0",
"@types/node": "^12.7.3", "@types/node": "^13.7.0",
"@types/shortid": "0.0.29", "@types/shortid": "0.0.29",
"mongodb-memory-server": "^5.2.0", "mongodb-memory-server": "^6.2.4",
"tslint": "^5.19.0", "tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [

View File

@ -29,14 +29,6 @@ tap.test('should create a testinstance as database', async () => {
testDb = new smartdata.SmartdataDb(smartdataOptions); testDb = new smartdata.SmartdataDb(smartdataOptions);
}); });
tap.skip.test('should create a smartdb', async () => {
testDb = new smartdata.SmartdataDb({
mongoDbName: testQenv.getEnvVarOnDemand('MONGO_DBNAME'),
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
mongoDbPass: testQenv.getEnvVarOnDemand('MONGO_PASS')
});
});
tap.test('should establish a connection to the rethink Db cluster', async () => { tap.test('should establish a connection to the rethink Db cluster', async () => {
await testDb.init(); await testDb.init();
}); });
@ -136,7 +128,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);
}); });

View File

@ -120,8 +120,6 @@ export class SmartdataCollection<T> {
await this.checkDoc(dbDocArg); await this.checkDoc(dbDocArg);
const identifiableObject = await dbDocArg.createIdentifiableObject(); const identifiableObject = await dbDocArg.createIdentifiableObject();
const saveableObject = await dbDocArg.createSavableObject(); const saveableObject = await dbDocArg.createSavableObject();
console.log(identifiableObject);
console.log(saveableObject);
const updateableObject: any = {}; const updateableObject: any = {};
for (const key of Object.keys(saveableObject)) { for (const key of Object.keys(saveableObject)) {
if (identifiableObject[key]) { if (identifiableObject[key]) {
@ -129,7 +127,6 @@ export class SmartdataCollection<T> {
} }
updateableObject[key] = saveableObject[key]; updateableObject[key] = saveableObject[key];
} }
console.log(updateableObject);
this.mongoDbCollection.updateOne( this.mongoDbCollection.updateOne(
identifiableObject, identifiableObject,
{ $set: updateableObject }, { $set: updateableObject },
@ -141,7 +138,9 @@ 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, {
w: 1
});
} }
/** /**

View File

@ -103,10 +103,8 @@ 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);
} }