Compare commits

..

7 Commits

Author SHA1 Message Date
138290a7b8 1.0.13 2016-09-13 10:23:49 +02:00
036cafc282 improve README 2016-09-13 10:23:46 +02:00
7764ba5cb8 1.0.12 2016-09-13 10:17:46 +02:00
7f77634ea1 imrpove README 2016-09-13 10:17:34 +02:00
acf3c29939 1.0.11 2016-09-13 00:14:54 +02:00
925cd639b4 imrpove README 2016-09-13 00:14:50 +02:00
af8de58dcd improve README 2016-09-13 00:13:00 +02:00
2 changed files with 26 additions and 4 deletions

View File

@ -1,5 +1,7 @@
# smartdata
> Note: Still in Beta
smartdata is a ODM that adheres to TypeScript practices and uses classes to organize data.
It uses MongoDB as persistent storage.
@ -31,7 +33,7 @@ myDb2.connect()
// continues in next block...
```
### class Collection
### class DbCollection
represents a collection of objects.
A collection is defined by the object class (that is extending smartdata.dbdoc) it respresents
@ -39,7 +41,7 @@ So to get to get access to a specific collection you document
```typescript
// continues from the block before...
class myObject extends smartdata.DbDoc {
class myObject extends smartdata.DbDoc { // read the next block about DbDoc
property1:string
property2:number
constructor(optionsArg:{
@ -59,9 +61,29 @@ let myCollection = myDb1.getCollection(myObject)
This is done for you!!!
### class DbDoc
represents a individual document in a collection.
represents a individual document in a collection
and thereby is ideally suited to extend the class you want to actually store.
DbDoc extends your class with the following methods:
* `.save()` will save (or update) the object you call it on only. Any referenced non-savable objects will not get stored.
* `.saveDeep()` does the same like `.save()`.
In addition it will look for properties that reference an object
that extends DbDoc as well and call .saveDeep() on them as well.
Loops are prevented
So now we can **store** instances of classes to Db...
How do we **get** a new class instance from a Doc in the DB?
Easy! Take a look at the constructor. When you specify `optionsArg.queryArg`
smartdata will fill in the data from the database!
But when you specify a `optionsArg.dataArg` instead
the data for the class is taken from there :)
## TypeScript
How does TypeScript play into this?
Since you define your classes in TapeScript and types flow through smartdata in a generic way
you should get all the Intellisense and type checking you love when using smartdata.
smartdata itself also bundles typings.
So you don't need to install any additional types whenimporting smartdata.
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

View File

@ -1,6 +1,6 @@
{
"name": "smartdata",
"version": "1.0.10",
"version": "1.0.13",
"description": "do more with data",
"main": "dist/index.js",
"typings": "dist/index.d.ts",