Compare commits

..

5 Commits

Author SHA1 Message Date
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
f39703b8d9 1.0.10 2016-09-13 00:04:20 +02:00
fa1951b4dd imrprove README 2016-09-13 00:04:07 +02:00
2 changed files with 17 additions and 6 deletions

View File

@ -27,22 +27,26 @@ let myDb2 = new smartdata.Db('someConnectionUrl')
myDb1.connect() myDb1.connect()
myDb2.connect() myDb2.connect()
// continues in next block...
``` ```
### class Collection ### class DbCollection
represents a collection of objects. represents a collection of objects.
A collection is defined by the object class (that is extending smartdata.dbdoc) it respresents A collection is defined by the object class (that is extending smartdata.dbdoc) it respresents
So to get to get access to a specific collection you document So to get to get access to a specific collection you document
```typescript ```typescript
class myObject extends DbDoc { // continues from the block before...
class myObject extends smartdata.DbDoc { // read the next block about DbDoc
property1:string property1:string
property2:number property2:number
constructor(optionsArg:{ constructor(optionsArg:{
queryArg?:any, queryArg?:any,
dataArg?:{ dataArg?:{
property1:string, property1:string,
property2:string property2:number
} }
}) { }) {
super(this,optionsArg) super(this,optionsArg)
@ -55,9 +59,16 @@ let myCollection = myDb1.getCollection(myObject)
This is done for you!!! This is done for you!!!
### class DbDoc ### 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 .save() and saveDeep() methods.
So now we can get store instances of classes to Db...
How do we get a new class instances from a Doc in 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 is for the class is taken from there :)
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks) [![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

View File

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