Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
766ae1d1ff | |||
7630882312 | |||
4aec47f207 | |||
c2e3a1ae6e |
16
README.md
16
README.md
@ -51,9 +51,16 @@ represents a Database. Naturally it has .connect() etc. methods on it.
|
|||||||
import * as smartdata from "smartdata";
|
import * as smartdata from "smartdata";
|
||||||
|
|
||||||
let myRethinkDb1 = new smartdata.Db({
|
let myRethinkDb1 = new smartdata.Db({
|
||||||
// rethinkDb connection options here
|
db: "test",
|
||||||
|
host: "https://some",
|
||||||
|
user: "testuser",
|
||||||
|
password: "testpass",
|
||||||
|
port: 1234
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// in case you need to support a proprietory ssl cert (e.g. compose.com):
|
||||||
|
myRethinkDb1.setSsl(process.env.RDB_CERT, "base64");
|
||||||
|
|
||||||
myDb1.connect();
|
myDb1.connect();
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -97,6 +104,7 @@ MyObject.getInstance<MyObject>({
|
|||||||
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.
|
||||||
|
|
||||||
|
**sStore** instances of classes to Db:
|
||||||
DbDoc extends your class with the following methods:
|
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.
|
* `.save()` will save (or update) the object you call it on only. Any referenced non-savable objects will not get stored.
|
||||||
@ -105,8 +113,10 @@ DbDoc extends your class with the following methods:
|
|||||||
that extends DbDoc as well and call .saveDeep() on them as well.
|
that extends DbDoc as well and call .saveDeep() on them as well.
|
||||||
Loops are prevented
|
Loops are prevented
|
||||||
|
|
||||||
So now we can **store** instances of classes to Db...
|
**Get** a new class instance from a Doc in the DB:
|
||||||
How do we **get** a new class instance from a Doc in the DB?
|
DbDoc exposes a static method that allows you specify a filter to retrieve a cloned class of the one you used to that doc at some point later in time. Yes, let that sink in a minute :)
|
||||||
|
|
||||||
|
So you can just call `.getInstance({ /* filter props here */ })`.
|
||||||
|
|
||||||
## TypeScript
|
## TypeScript
|
||||||
|
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartdata",
|
"name": "smartdata",
|
||||||
"version": "2.0.4",
|
"version": "2.0.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartdata",
|
"name": "smartdata",
|
||||||
"version": "2.0.4",
|
"version": "2.0.6",
|
||||||
"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