Commit 0b8adea7 authored by PhilKunz's avatar PhilKunz
Browse files

improve README

parent 90d9a25b
......@@ -63,11 +63,11 @@ So to get to get access to a specific collection you document
@Collection(myDb1)
class myObject extends smartdata.DbDoc<myObject> { // read the next block about DbDoc
property1:string
property2:number
@smartdata.saveable property1: string // @smartdata.saveable marks the property for db save
property2: number // this one is not marked, so it won't be save upon calling this.save()
constructor(optionsArg:{
property1:string,
property2:number
property1: string,
property2: number
}) {
super()
}
......
import { DbCollection } from './smartdata.classes.dbcollection';
export declare type TDocCreation = 'db' | 'data' | 'mixed';
export declare type TDocCreation = 'db' | 'new' | 'mixed';
/**
* sva - saveable decorator to be used on class properties
*/
......
......@@ -23,7 +23,7 @@ describe('mongodb', function () {
this.timeout(30000)
mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017', { async: true, silent: true })
let doneCalled = false
mongoChildProcess.stdout.on('data', function (data) {
mongoChildProcess.stdout.on('new', function (data) {
console.log(smartstring.indent.indentWithPrefix(data, '*** MongoDB Process *** : '))
if (!doneCalled) {
if (/waiting for connections on port 27017/.test(data)) {
......
......@@ -3,10 +3,10 @@ import * as plugins from './smartdata.plugins'
import { Db } from './smartdata.classes.db'
import { DbCollection } from './smartdata.classes.dbcollection'
export type TDocCreation = 'db' | 'data' | 'mixed'
export type TDocCreation = 'db' | 'new' | 'mixed'
/**
* sva - saveable decorator to be used on class properties
* saveable - saveable decorator to be used on class properties
*/
export function saveable(target: DbDoc<any>, key: string) {
console.log('called sva')
......@@ -47,6 +47,13 @@ export class DbDoc<T> {
for (let propertyNameString of this.saveableProperties) {
saveableObject[propertyNameString] = this[propertyNameString]
}
switch (this.creationType) {
case 'db':
this.collection // TODO implement collection.update()
break
case 'new':
this.collection.insertOne(saveableObject)
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment