Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
138290a7b8 | |||
036cafc282 | |||
7764ba5cb8 | |||
7f77634ea1 |
23
README.md
23
README.md
@ -1,5 +1,7 @@
|
|||||||
# smartdata
|
# smartdata
|
||||||
|
|
||||||
|
> Note: Still in Beta
|
||||||
|
|
||||||
smartdata is a ODM that adheres to TypeScript practices and uses classes to organize data.
|
smartdata is a ODM that adheres to TypeScript practices and uses classes to organize data.
|
||||||
It uses MongoDB as persistent storage.
|
It uses MongoDB as persistent storage.
|
||||||
|
|
||||||
@ -62,13 +64,26 @@ This is done for you!!!
|
|||||||
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.
|
and thereby is ideally suited to extend the class you want to actually store.
|
||||||
|
|
||||||
DbDoc extends your class with .save() and saveDeep() methods.
|
DbDoc extends your class with the following methods:
|
||||||
|
|
||||||
So now we can get store instances of classes to Db...
|
* `.save()` will save (or update) the object you call it on only. Any referenced non-savable objects will not get stored.
|
||||||
How do we get a new class instances from a Doc in DB?
|
* `.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`
|
Easy! Take a look at the constructor. When you specify `optionsArg.queryArg`
|
||||||
smartdata will fill in the data from the database!
|
smartdata will fill in the data from the database!
|
||||||
But when you specify a `optionsArg.dataArg` instead
|
But when you specify a `optionsArg.dataArg` instead
|
||||||
the data is for the class is taken from there :)
|
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.
|
||||||
|
|
||||||
[](https://push.rocks)
|
[](https://push.rocks)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartdata",
|
"name": "smartdata",
|
||||||
"version": "1.0.11",
|
"version": "1.0.13",
|
||||||
"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",
|
||||||
|
Reference in New Issue
Block a user