update deps and docs
This commit is contained in:
parent
2d97ab9dc5
commit
8101e49026
87
README.md
87
README.md
@ -1,5 +1,5 @@
|
|||||||
# smartdata
|
# smartdata
|
||||||
do more with data
|
do more with data and RethinkDB
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty
|
||||||
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartdata)
|
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartdata)
|
||||||
@ -21,6 +21,91 @@ do more with data
|
|||||||
## Usage
|
## Usage
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
smartdata is an ODM that adheres to TypeScript practices and uses classes to organize data.
|
||||||
|
It uses RethinkDB as persistent storage.
|
||||||
|
|
||||||
|
## Intention
|
||||||
|
There are many ODMs out there, however when we searched for an ODM that uses TypeScript,
|
||||||
|
acts smart while still embracing the NoSQL idea we didn't find a matching solution.
|
||||||
|
This is why we started smartdata.
|
||||||
|
|
||||||
|
How MongoDB terms map to smartdata classes
|
||||||
|
|
||||||
|
RethinkDB term | smartdata class
|
||||||
|
--- | ---
|
||||||
|
Database | smartdata.Db
|
||||||
|
Table | smartdata.DbTable
|
||||||
|
Document | smartdata.DbDoc
|
||||||
|
|
||||||
|
### class Db
|
||||||
|
represents a Database. Naturally it has .connect() etc. methods on it.
|
||||||
|
```javascript
|
||||||
|
import * as smartdata from 'smartdata'
|
||||||
|
|
||||||
|
// mongodb
|
||||||
|
let myDb1 = new smartdata.Db({
|
||||||
|
// rethinkDb connection options here
|
||||||
|
})
|
||||||
|
|
||||||
|
myDb1.connect()
|
||||||
|
```
|
||||||
|
|
||||||
|
### class DbCollection
|
||||||
|
represents a collection of objects.
|
||||||
|
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
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// continues from the block before...
|
||||||
|
|
||||||
|
@Collection(myDb1)
|
||||||
|
class MyObject extends smartdata.DbDoc<myObject> { // read the next block about DbDoc
|
||||||
|
@smartdata.svDb() property1: string // @smartdata.svDb() 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
|
||||||
|
}) {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let myCollection = myDb1.getCollectionByName<myObject>(myObject)
|
||||||
|
|
||||||
|
// start to instantiate instances of classes from scratch or database
|
||||||
|
|
||||||
|
let localObject = new MyObject({
|
||||||
|
property1: 'hi',
|
||||||
|
property2: 2
|
||||||
|
})
|
||||||
|
localObject.save() // saves the object to the database
|
||||||
|
```
|
||||||
|
|
||||||
|
> Alert: You NEVER instantiate a collection.
|
||||||
|
This is done for you!!!
|
||||||
|
|
||||||
|
### class DbDoc
|
||||||
|
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?
|
||||||
|
|
||||||
|
## TypeScript
|
||||||
|
How does TypeScript play into this?
|
||||||
|
Since you define your classes in TypeScript 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 when importing smartdata.
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
@ -18,99 +18,6 @@ do more with data
|
|||||||
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
|
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
|
||||||
|
|
||||||
## Usage
|
|
||||||
Use TypeScript for best in class instellisense.
|
|
||||||
|
|
||||||
smartdata is an ODM that adheres to TypeScript practices and uses classes to organize data.
|
|
||||||
It uses MongoDB or NeDb as persistent storage.
|
|
||||||
|
|
||||||
## Intention
|
|
||||||
There are many ODMs out there, however when we searched for an ODM that uses TypeScript,
|
|
||||||
acts smart while still embracing the NoSQL idea we didn't find a matching solution.
|
|
||||||
This is why we started smartdata.
|
|
||||||
|
|
||||||
How MongoDB terms map to smartdata classes
|
|
||||||
|
|
||||||
MongoDB term | smartdata class
|
|
||||||
--- | ---
|
|
||||||
Database | smartdata.Db
|
|
||||||
Collection | smartdata.DbCollection
|
|
||||||
Document | smartdata.DbDoc
|
|
||||||
|
|
||||||
### class Db
|
|
||||||
represents a Database. Naturally it has .connect() etc. methods on it.
|
|
||||||
Since it is a class you can have multiple DBs defined.
|
|
||||||
```javascript
|
|
||||||
import * as smartdata from 'smartdata'
|
|
||||||
|
|
||||||
// mongodb
|
|
||||||
let myDb1 = new smartdata.Db('someConnectionUrl')
|
|
||||||
let myDb2 = new smartdata.Db('someConnectionUrl')
|
|
||||||
|
|
||||||
// nedb
|
|
||||||
let myDb3 = new smartdata('/some/path/for/persistence', 'nedb') // you may set first argument to null for just in memory db
|
|
||||||
|
|
||||||
myDb1.connect()
|
|
||||||
myDb2.connect()
|
|
||||||
|
|
||||||
// continues in next block...
|
|
||||||
```
|
|
||||||
|
|
||||||
### class DbCollection
|
|
||||||
represents a collection of objects.
|
|
||||||
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
|
|
||||||
```javascript
|
|
||||||
// continues from the block before...
|
|
||||||
|
|
||||||
@Collection(myDb1)
|
|
||||||
class MyObject extends smartdata.DbDoc<myObject> { // read the next block about DbDoc
|
|
||||||
@smartdata.svDb() property1: string // @smartdata.svDb() 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
|
|
||||||
}) {
|
|
||||||
super()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let myCollection = myDb1.getCollectionByName<myObject>(myObject)
|
|
||||||
|
|
||||||
// start to instantiate instances of classes from scratch or database
|
|
||||||
|
|
||||||
let localObject = new MyObject({
|
|
||||||
property1: 'hi',
|
|
||||||
property2: 2
|
|
||||||
})
|
|
||||||
localObject.save() // saves the object to the database
|
|
||||||
```
|
|
||||||
|
|
||||||
> Alert: You NEVER instantiate a collection.
|
|
||||||
This is done for you!!!
|
|
||||||
|
|
||||||
### class DbDoc
|
|
||||||
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?
|
|
||||||
|
|
||||||
## TypeScript
|
|
||||||
How does TypeScript play into this?
|
|
||||||
Since you define your classes in TypeScript 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 when importing smartdata.
|
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
208
package-lock.json
generated
Normal file
208
package-lock.json
generated
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
{
|
||||||
|
"name": "smartdata",
|
||||||
|
"version": "1.0.28",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/bson": {
|
||||||
|
"version": "1.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/bson/-/bson-1.0.6.tgz",
|
||||||
|
"integrity": "sha512-v7N8qcTGiYhLRyi+Y69R3tPC4GLqByCg3NC2EO6PciC166O9dNhjFPoXeMePtZ+0f+/O2xLDWXs5BLnRfcBaBA==",
|
||||||
|
"requires": {
|
||||||
|
"@types/node": "8.5.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/events": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/events/-/events-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-y3bR98mzYOo0pAZuiLari+cQyiKk3UXRuT45h1RjhfeCzqkjaVsfZJNaxdgtk7/3tzOm1ozLTqEqMP3VbI48jw=="
|
||||||
|
},
|
||||||
|
"@types/lodash": {
|
||||||
|
"version": "4.14.92",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.92.tgz",
|
||||||
|
"integrity": "sha512-cdvY1fyUGYgG7/i07a/sR5PnD6+Z+ljUrD0CNVf0qj645VvEdLNtZPjvCp4siPy3rQ/KRXMfUATIqi3+9x57Sw=="
|
||||||
|
},
|
||||||
|
"@types/minimatch": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||||
|
},
|
||||||
|
"@types/mongodb": {
|
||||||
|
"version": "2.2.18",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-2.2.18.tgz",
|
||||||
|
"integrity": "sha512-bNookS+Y4N7B9/z9lZrTcVUdXSfrH8J+svBFCzxbCl5pOg32YeIgvKjrqD4yF7Ecec7bo7ZCdqajXS06TeuWdA==",
|
||||||
|
"requires": {
|
||||||
|
"@types/bson": "1.0.6",
|
||||||
|
"@types/events": "1.1.0",
|
||||||
|
"@types/node": "8.5.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/node": {
|
||||||
|
"version": "8.5.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.5.7.tgz",
|
||||||
|
"integrity": "sha512-+1ZfzGIq8Y3EV7hPF7bs3i+Gi2mqYOiEGGRxGYPrn+hTYLMmzg+/5TkMkCHiRtLB38XSNvr/43aQ9+cUq4BbBg=="
|
||||||
|
},
|
||||||
|
"balanced-match": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||||
|
},
|
||||||
|
"brace-expansion": {
|
||||||
|
"version": "1.1.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz",
|
||||||
|
"integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=",
|
||||||
|
"requires": {
|
||||||
|
"balanced-match": "1.0.0",
|
||||||
|
"concat-map": "0.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"concat-map": {
|
||||||
|
"version": "0.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
|
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||||
|
},
|
||||||
|
"define-properties": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz",
|
||||||
|
"integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=",
|
||||||
|
"requires": {
|
||||||
|
"foreach": "2.0.5",
|
||||||
|
"object-keys": "1.0.11"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"es-abstract": {
|
||||||
|
"version": "1.10.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.10.0.tgz",
|
||||||
|
"integrity": "sha512-/uh/DhdqIOSkAWifU+8nG78vlQxdLckUdI/sPgy0VhuXi2qJ7T8czBmqIYtLQVpCIFYafChnsRsB5pyb1JdmCQ==",
|
||||||
|
"requires": {
|
||||||
|
"es-to-primitive": "1.1.1",
|
||||||
|
"function-bind": "1.1.1",
|
||||||
|
"has": "1.0.1",
|
||||||
|
"is-callable": "1.1.3",
|
||||||
|
"is-regex": "1.0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"es-to-primitive": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz",
|
||||||
|
"integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=",
|
||||||
|
"requires": {
|
||||||
|
"is-callable": "1.1.3",
|
||||||
|
"is-date-object": "1.0.1",
|
||||||
|
"is-symbol": "1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"foreach": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
|
||||||
|
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k="
|
||||||
|
},
|
||||||
|
"function-bind": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
||||||
|
},
|
||||||
|
"has": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=",
|
||||||
|
"requires": {
|
||||||
|
"function-bind": "1.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is-callable": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz",
|
||||||
|
"integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI="
|
||||||
|
},
|
||||||
|
"is-date-object": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY="
|
||||||
|
},
|
||||||
|
"is-regex": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
|
||||||
|
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
|
||||||
|
"requires": {
|
||||||
|
"has": "1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is-symbol": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
|
||||||
|
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI="
|
||||||
|
},
|
||||||
|
"lik": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/lik/-/lik-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-xdNrvQqVLMNkU25Z6tNrJXyOhn0hugZvWZCIPb315M5J4fK2OzgpLacp68J5bYWydRWX4L3Tl/i69BNWHsvcXg==",
|
||||||
|
"requires": {
|
||||||
|
"@types/lodash": "4.14.92",
|
||||||
|
"@types/minimatch": "3.0.3",
|
||||||
|
"lodash": "4.17.4",
|
||||||
|
"minimatch": "3.0.4",
|
||||||
|
"smartq": "1.1.6",
|
||||||
|
"symbol-tree": "3.2.2",
|
||||||
|
"typings-global": "1.0.28"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"lodash": {
|
||||||
|
"version": "4.17.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
|
||||||
|
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
|
||||||
|
},
|
||||||
|
"smartq": {
|
||||||
|
"version": "1.1.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/smartq/-/smartq-1.1.6.tgz",
|
||||||
|
"integrity": "sha512-W7vTj4kSqN8kHVq+Q6BJTr/UGc36TnO0pzKNU8B4cr7TXG4N98eyubWaaCHPSjCUqDgmUPPru929WXzetai97A==",
|
||||||
|
"requires": {
|
||||||
|
"typings-global": "1.0.28",
|
||||||
|
"util.promisify": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimatch": {
|
||||||
|
"version": "3.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
|
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||||
|
"requires": {
|
||||||
|
"brace-expansion": "1.1.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"object-keys": {
|
||||||
|
"version": "1.0.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz",
|
||||||
|
"integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0="
|
||||||
|
},
|
||||||
|
"object.getownpropertydescriptors": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz",
|
||||||
|
"integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=",
|
||||||
|
"requires": {
|
||||||
|
"define-properties": "1.1.2",
|
||||||
|
"es-abstract": "1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"symbol-tree": {
|
||||||
|
"version": "3.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
|
||||||
|
"integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY="
|
||||||
|
},
|
||||||
|
"typings-global": {
|
||||||
|
"version": "1.0.28",
|
||||||
|
"resolved": "https://registry.npmjs.org/typings-global/-/typings-global-1.0.28.tgz",
|
||||||
|
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A=="
|
||||||
|
},
|
||||||
|
"util.promisify": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==",
|
||||||
|
"requires": {
|
||||||
|
"define-properties": "1.1.2",
|
||||||
|
"object.getownpropertydescriptors": "2.0.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,17 +19,15 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartdata#README",
|
"homepage": "https://gitlab.com/pushrocks/smartdata#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/lodash": "^4.14.74",
|
"@types/lodash": "^4.14.92",
|
||||||
"@types/mongodb": "^2.2.11",
|
|
||||||
"@types/rethinkdb": "^2.3.8",
|
"@types/rethinkdb": "^2.3.8",
|
||||||
"beautylog": "^6.1.10",
|
"beautylog": "^6.1.10",
|
||||||
"lik": "^1.0.40",
|
"lik": "^2.0.2",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"mongodb": "^2.2.31",
|
|
||||||
"rethinkdb": "^2.3.3",
|
"rethinkdb": "^2.3.3",
|
||||||
"runtime-type-checks": "0.0.4",
|
"runtime-type-checks": "0.0.4",
|
||||||
"smartq": "^1.1.6",
|
"smartq": "^1.1.6",
|
||||||
"typings-global": "^1.0.20"
|
"typings-global": "^1.0.28"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/shelljs": "^0.7.4",
|
"@types/shelljs": "^0.7.4",
|
||||||
|
@ -22,19 +22,17 @@ export class DbTable<T> {
|
|||||||
* can be nedb datastore (sub api of mongodb)
|
* can be nedb datastore (sub api of mongodb)
|
||||||
*/
|
*/
|
||||||
table: plugins.rethinkDb.Table
|
table: plugins.rethinkDb.Table
|
||||||
collectedClass: T & DbDoc<T>
|
|
||||||
objectValidation: IDocValidation<T> = null
|
objectValidation: IDocValidation<T> = null
|
||||||
name: string
|
name: string
|
||||||
db: Db
|
db: Db
|
||||||
|
|
||||||
constructor (collectedClassArg: T & DbDoc<T>, dbArg: Db) {
|
constructor (collectedClassArg: T & DbDoc<T>, dbArg: Db) {
|
||||||
// tell the collection where it belongs
|
// tell the collection where it belongs
|
||||||
this.collectedClass = collectedClassArg
|
|
||||||
this.name = collectedClassArg.name
|
this.name = collectedClassArg.name
|
||||||
this.db = dbArg
|
this.db = dbArg
|
||||||
|
|
||||||
// make sure it actually exists
|
// connect this instance to a RethinkDB table
|
||||||
this.table = dbArg.dbConnection.collection(this.name)
|
this.table = plugins.rethinkDb.db(this.db.dbName).table(this.name)
|
||||||
|
|
||||||
// tell the db class about it (important since Db uses different systems under the hood)
|
// tell the db class about it (important since Db uses different systems under the hood)
|
||||||
this.db.addCollection(this)
|
this.db.addCollection(this)
|
||||||
|
97
yarn.lock
97
yarn.lock
@ -2,12 +2,6 @@
|
|||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
"@types/bson@*":
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/bson/-/bson-1.0.4.tgz#94260b6b96fa459346959c9216799d8919e95d2b"
|
|
||||||
dependencies:
|
|
||||||
"@types/node" "*"
|
|
||||||
|
|
||||||
"@types/code@^4.0.3":
|
"@types/code@^4.0.3":
|
||||||
version "4.0.3"
|
version "4.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/@types/code/-/code-4.0.3.tgz#9c4de39f86eb3eba070146d2dab7dbc3f8eac35f"
|
resolved "https://registry.yarnpkg.com/@types/code/-/code-4.0.3.tgz#9c4de39f86eb3eba070146d2dab7dbc3f8eac35f"
|
||||||
@ -29,17 +23,14 @@
|
|||||||
version "4.14.85"
|
version "4.14.85"
|
||||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.85.tgz#a16fbf942422f6eca5622b6910492c496c35069b"
|
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.85.tgz#a16fbf942422f6eca5622b6910492c496c35069b"
|
||||||
|
|
||||||
|
"@types/lodash@^4.14.92":
|
||||||
|
version "4.14.92"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.92.tgz#6e3cb0b71a1e12180a47a42a744e856c3ae99a57"
|
||||||
|
|
||||||
"@types/minimatch@*", "@types/minimatch@3.x.x":
|
"@types/minimatch@*", "@types/minimatch@3.x.x":
|
||||||
version "3.0.1"
|
version "3.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.1.tgz#b683eb60be358304ef146f5775db4c0e3696a550"
|
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.1.tgz#b683eb60be358304ef146f5775db4c0e3696a550"
|
||||||
|
|
||||||
"@types/mongodb@^2.2.11":
|
|
||||||
version "2.2.15"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/mongodb/-/mongodb-2.2.15.tgz#42577d8a92b9840dad440acf92fea6435c1fcfb3"
|
|
||||||
dependencies:
|
|
||||||
"@types/bson" "*"
|
|
||||||
"@types/node" "*"
|
|
||||||
|
|
||||||
"@types/node@*", "@types/node@^8.0.33":
|
"@types/node@*", "@types/node@^8.0.33":
|
||||||
version "8.0.53"
|
version "8.0.53"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.53.tgz#396b35af826fa66aad472c8cb7b8d5e277f4e6d8"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.53.tgz#396b35af826fa66aad472c8cb7b8d5e277f4e6d8"
|
||||||
@ -124,14 +115,6 @@ brace-expansion@^1.1.7:
|
|||||||
balanced-match "^1.0.0"
|
balanced-match "^1.0.0"
|
||||||
concat-map "0.0.1"
|
concat-map "0.0.1"
|
||||||
|
|
||||||
bson@~1.0.4:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/bson/-/bson-1.0.4.tgz#93c10d39eaa5b58415cbc4052f3e53e562b0b72c"
|
|
||||||
|
|
||||||
buffer-shims@~1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51"
|
|
||||||
|
|
||||||
chalk@^1.0.0, chalk@^1.1.1:
|
chalk@^1.0.0, chalk@^1.1.1:
|
||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
|
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
|
||||||
@ -227,10 +210,6 @@ es6-error@^4.0.2:
|
|||||||
version "4.0.2"
|
version "4.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.0.2.tgz#eec5c726eacef51b7f6b73c20db6e1b13b069c98"
|
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.0.2.tgz#eec5c726eacef51b7f6b73c20db6e1b13b069c98"
|
||||||
|
|
||||||
es6-promise@3.2.1:
|
|
||||||
version "3.2.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.2.1.tgz#ec56233868032909207170c39448e24449dd1fc4"
|
|
||||||
|
|
||||||
escape-string-regexp@^1.0.2:
|
escape-string-regexp@^1.0.2:
|
||||||
version "1.0.5"
|
version "1.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
||||||
@ -313,7 +292,7 @@ inflight@^1.0.4:
|
|||||||
once "^1.3.0"
|
once "^1.3.0"
|
||||||
wrappy "1"
|
wrappy "1"
|
||||||
|
|
||||||
inherits@2, inherits@^2.0.1, inherits@~2.0.1, inherits@~2.0.3:
|
inherits@2, inherits@^2.0.1, inherits@~2.0.3:
|
||||||
version "2.0.3"
|
version "2.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||||
|
|
||||||
@ -404,16 +383,16 @@ left-pad@^1.1.3:
|
|||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.3.tgz#612f61c033f3a9e08e939f1caebeea41b6f3199a"
|
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.3.tgz#612f61c033f3a9e08e939f1caebeea41b6f3199a"
|
||||||
|
|
||||||
lik@^1.0.40:
|
lik@^2.0.2:
|
||||||
version "1.0.43"
|
version "2.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/lik/-/lik-1.0.43.tgz#e81709290fb85ff61dabfa008791ba9ffed0c666"
|
resolved "https://registry.yarnpkg.com/lik/-/lik-2.0.2.tgz#da4e67458ab81fac9e62848e8e76dc1efe1c646f"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/lodash" "^4.14.74"
|
"@types/lodash" "^4.14.74"
|
||||||
"@types/minimatch" "3.x.x"
|
"@types/minimatch" "3.x.x"
|
||||||
lodash "^4.17.4"
|
lodash "^4.17.4"
|
||||||
minimatch "^3.0.4"
|
minimatch "^3.0.4"
|
||||||
rxjs "^5.4.3"
|
|
||||||
smartq "^1.1.6"
|
smartq "^1.1.6"
|
||||||
|
symbol-tree "^3.2.2"
|
||||||
typings-global "^1.0.20"
|
typings-global "^1.0.20"
|
||||||
|
|
||||||
lodash@^4.17.4:
|
lodash@^4.17.4:
|
||||||
@ -447,21 +426,6 @@ minimist@^1.2.0:
|
|||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
|
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
|
||||||
|
|
||||||
mongodb-core@2.1.17:
|
|
||||||
version "2.1.17"
|
|
||||||
resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.17.tgz#a418b337a14a14990fb510b923dee6a813173df8"
|
|
||||||
dependencies:
|
|
||||||
bson "~1.0.4"
|
|
||||||
require_optional "~1.0.0"
|
|
||||||
|
|
||||||
mongodb@^2.2.31:
|
|
||||||
version "2.2.33"
|
|
||||||
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.33.tgz#b537c471d34a6651b48f36fdbf29750340e08b50"
|
|
||||||
dependencies:
|
|
||||||
es6-promise "3.2.1"
|
|
||||||
mongodb-core "2.1.17"
|
|
||||||
readable-stream "2.2.7"
|
|
||||||
|
|
||||||
nan@^2.3.2:
|
nan@^2.3.2:
|
||||||
version "2.8.0"
|
version "2.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a"
|
resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a"
|
||||||
@ -541,18 +505,6 @@ randomatic@^1.1.7:
|
|||||||
is-number "^3.0.0"
|
is-number "^3.0.0"
|
||||||
kind-of "^4.0.0"
|
kind-of "^4.0.0"
|
||||||
|
|
||||||
readable-stream@2.2.7:
|
|
||||||
version "2.2.7"
|
|
||||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.7.tgz#07057acbe2467b22042d36f98c5ad507054e95b1"
|
|
||||||
dependencies:
|
|
||||||
buffer-shims "~1.0.0"
|
|
||||||
core-util-is "~1.0.0"
|
|
||||||
inherits "~2.0.1"
|
|
||||||
isarray "~1.0.0"
|
|
||||||
process-nextick-args "~1.0.6"
|
|
||||||
string_decoder "~1.0.0"
|
|
||||||
util-deprecate "~1.0.1"
|
|
||||||
|
|
||||||
readable-stream@^2.0.2, readable-stream@^2.1.5:
|
readable-stream@^2.0.2, readable-stream@^2.1.5:
|
||||||
version "2.3.3"
|
version "2.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c"
|
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c"
|
||||||
@ -587,17 +539,6 @@ require-reload@0.2.2:
|
|||||||
version "0.2.2"
|
version "0.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/require-reload/-/require-reload-0.2.2.tgz#29a7591846caf91b6e8a3cda991683f95f8d7d42"
|
resolved "https://registry.yarnpkg.com/require-reload/-/require-reload-0.2.2.tgz#29a7591846caf91b6e8a3cda991683f95f8d7d42"
|
||||||
|
|
||||||
require_optional@~1.0.0:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/require_optional/-/require_optional-1.0.1.tgz#4cf35a4247f64ca3df8c2ef208cc494b1ca8fc2e"
|
|
||||||
dependencies:
|
|
||||||
resolve-from "^2.0.0"
|
|
||||||
semver "^5.1.0"
|
|
||||||
|
|
||||||
resolve-from@^2.0.0:
|
|
||||||
version "2.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-2.0.0.tgz#9480ab20e94ffa1d9e80a804c7ea147611966b57"
|
|
||||||
|
|
||||||
resolve@^1.1.6:
|
resolve@^1.1.6:
|
||||||
version "1.5.0"
|
version "1.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"
|
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"
|
||||||
@ -623,17 +564,11 @@ runtime-type-checks@0.0.4:
|
|||||||
dependencies:
|
dependencies:
|
||||||
reflect-metadata "^0.1.2"
|
reflect-metadata "^0.1.2"
|
||||||
|
|
||||||
rxjs@^5.4.3:
|
|
||||||
version "5.5.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.2.tgz#28d403f0071121967f18ad665563255d54236ac3"
|
|
||||||
dependencies:
|
|
||||||
symbol-observable "^1.0.1"
|
|
||||||
|
|
||||||
safe-buffer@~5.1.0, safe-buffer@~5.1.1:
|
safe-buffer@~5.1.0, safe-buffer@~5.1.1:
|
||||||
version "5.1.1"
|
version "5.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
|
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
|
||||||
|
|
||||||
semver@^5.1.0, semver@^5.3.0:
|
semver@^5.3.0:
|
||||||
version "5.4.1"
|
version "5.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
|
||||||
|
|
||||||
@ -734,7 +669,7 @@ sprintf-js@~1.0.2:
|
|||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
|
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
|
||||||
|
|
||||||
string_decoder@~1.0.0, string_decoder@~1.0.3:
|
string_decoder@~1.0.3:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab"
|
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab"
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -773,9 +708,9 @@ supports-color@^2.0.0:
|
|||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
|
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
|
||||||
|
|
||||||
symbol-observable@^1.0.1:
|
symbol-tree@^3.2.2:
|
||||||
version "1.0.4"
|
version "3.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d"
|
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"
|
||||||
|
|
||||||
tapbundle@^1.1.1:
|
tapbundle@^1.1.1:
|
||||||
version "1.1.8"
|
version "1.1.8"
|
||||||
@ -803,6 +738,10 @@ typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.17, typings-
|
|||||||
semver "^5.3.0"
|
semver "^5.3.0"
|
||||||
smartshell "^1.0.6"
|
smartshell "^1.0.6"
|
||||||
|
|
||||||
|
typings-global@^1.0.28:
|
||||||
|
version "1.0.28"
|
||||||
|
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.28.tgz#e28cc965476564cbc00e438739e0aa0735d323d4"
|
||||||
|
|
||||||
universalify@^0.1.0:
|
universalify@^0.1.0:
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"
|
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"
|
||||||
|
Loading…
Reference in New Issue
Block a user