Compare commits

..

4 Commits

Author SHA1 Message Date
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 11 additions and 11 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartdata", "name": "@pushrocks/smartdata",
"version": "3.1.21", "version": "3.1.23",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartdata", "name": "@pushrocks/smartdata",
"version": "3.1.21", "version": "3.1.23",
"private": false, "private": false,
"description": "do more with data", "description": "do more with data",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -136,7 +136,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,11 +103,9 @@ 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);
} }
return returnArray; return returnArray;