Compare commits

..

5 Commits

Author SHA1 Message Date
c6cbff1308 3.1.14 2019-02-13 22:08:58 +01:00
3eeac7b936 fix(structure): format 2019-02-13 22:08:58 +01:00
761b742e21 3.1.13 2019-01-08 19:55:14 +01:00
e56def621c fix(core): update 2019-01-08 19:55:13 +01:00
ab1799f4f2 3.1.12 2019-01-08 18:59:36 +01:00
10 changed files with 41 additions and 43 deletions

View File

@ -1,25 +1,19 @@
# @pushrocks/smartdata # @pushrocks/smartdata
do more with data
do more with data and RethinkDB ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartdata)
## Availabililty * [gitlab.com (source)](https://gitlab.com/pushrocks/smartdata)
* [github.com (source mirror)](https://github.com/pushrocks/smartdata)
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartdata) * [docs (typedoc)](https://pushrocks.gitlab.io/smartdata/)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartdata)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartdata)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartdata/)
## Status for master ## Status for master
[![build status](https://gitlab.com/pushrocks/smartdata/badges/master/build.svg)](https://gitlab.com/pushrocks/smartdata/commits/master)
[![build status](https://GitLab.com/pushrocks/smartdata/badges/master/build.svg)](https://GitLab.com/pushrocks/smartdata/commits/master) [![coverage report](https://gitlab.com/pushrocks/smartdata/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartdata/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartdata/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartdata/commits/master) [![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartdata.svg)](https://www.npmjs.com/package/@pushrocks/smartdata)
[![npm downloads per month](https://img.shields.io/npm/dm/smartdata.svg)](https://www.npmjs.com/package/smartdata) [![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartdata/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartdata)
[![Dependency Status](https://david-dm.org/pushrocks/smartdata.svg)](https://david-dm.org/pushrocks/smartdata) [![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartdata/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartdata/master/dependencies/npm) [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartdata/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartdata)
[![Known Vulnerabilities](https://snyk.io/test/npm/smartdata/badge.svg)](https://snyk.io/test/npm/smartdata)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.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 ## Usage
@ -121,9 +115,9 @@ you should get all the Intellisense and type checking you love when using smartd
smartdata itself also bundles typings. smartdata itself also bundles typings.
So you don't need to install any additional types when importing smartdata. 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)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks) [![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -8,5 +8,15 @@
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public", "npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org" "npmRegistryUrl": "registry.npmjs.org"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartdata",
"shortDescription": "do more with data",
"npmPackagename": "@pushrocks/smartdata",
"license": "MIT"
}
} }
} }

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartdata", "name": "@pushrocks/smartdata",
"version": "3.1.11", "version": "3.1.14",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartdata", "name": "@pushrocks/smartdata",
"version": "3.1.11", "version": "3.1.14",
"private": false, "private": false,
"description": "do more with data", "description": "do more with data",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -20,7 +20,7 @@ let testDb = new smartdata.SmartdataDb({
}); });
tap.test('should establish a connection to the rethink Db cluster', async () => { tap.test('should establish a connection to the rethink Db cluster', async () => {
await testDb.connect(); await testDb.init();
}); });
// ======================================= // =======================================

View File

@ -29,7 +29,6 @@ export function Collection(dbArg: SmartdataDb | TDelayedDbCreation) {
return new SmartdataCollection(constructor, dbArg()); return new SmartdataCollection(constructor, dbArg());
}; };
} }
}; };
} }
@ -124,7 +123,7 @@ export class SmartdataCollection<T> {
this.mongoDbCollection.updateOne(identifiableObject, saveableObject); this.mongoDbCollection.updateOne(identifiableObject, saveableObject);
} }
public async delete (dbDocArg: T & SmartDataDbDoc<T>): Promise<any> { public async delete(dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
await this.init(); await this.init();
await this.checkDoc(dbDocArg); await this.checkDoc(dbDocArg);
const identifiableObject = await dbDocArg.createIdentifiableObject(); const identifiableObject = await dbDocArg.createIdentifiableObject();

View File

@ -44,7 +44,7 @@ export class SmartdataDb {
/** /**
* connects to the database that was specified during instance creation * connects to the database that was specified during instance creation
*/ */
async connect(): Promise<any> { async init(): Promise<any> {
let finalConnectionUrl = this.smartdataOptions.mongoDbUrl; let finalConnectionUrl = this.smartdataOptions.mongoDbUrl;
if (this.smartdataOptions.mongoDbPass) { if (this.smartdataOptions.mongoDbPass) {
finalConnectionUrl = mongoHelpers.addPassword( finalConnectionUrl = mongoHelpers.addPassword(
@ -53,12 +53,9 @@ export class SmartdataDb {
); );
} }
console.log(finalConnectionUrl); console.log(finalConnectionUrl);
this.mongoDbClient = await plugins.mongodb.MongoClient.connect( this.mongoDbClient = await plugins.mongodb.MongoClient.connect(finalConnectionUrl, {
finalConnectionUrl,
{
useNewUrlParser: true useNewUrlParser: true
} });
);
this.mongoDb = this.mongoDbClient.db(this.smartdataOptions.mongoDbName); this.mongoDb = this.mongoDbClient.db(this.smartdataOptions.mongoDbName);
this.status = 'connected'; this.status = 'connected';
console.log(`Connected to database ${this.smartdataOptions.mongoDbName}`); console.log(`Connected to database ${this.smartdataOptions.mongoDbName}`);

View File

@ -77,7 +77,7 @@ export class SmartDataDbDoc<T> {
*/ */
constructor() { constructor() {
this.name = this.constructor['name']; this.name = this.constructor['name'];
if(this.constructor['smartdataCollection']) { if (this.constructor['smartdataCollection']) {
// tslint:disable-next-line: no-string-literal // tslint:disable-next-line: no-string-literal
this.collection = this.constructor['smartdataCollection']; this.collection = this.constructor['smartdataCollection'];
// tslint:disable-next-line: no-string-literal // tslint:disable-next-line: no-string-literal
@ -97,7 +97,7 @@ export class SmartDataDbDoc<T> {
referenceMongoDBCollection = self.smartdataCollection; referenceMongoDBCollection = self.smartdataCollection;
} else if (self.smartdataDelayedCollection) { } else if (self.smartdataDelayedCollection) {
referenceMongoDBCollection = self.smartdataDelayedCollection(); referenceMongoDBCollection = self.smartdataDelayedCollection();
}; }
const foundDocs = await referenceMongoDBCollection.find(filterArg); const foundDocs = await referenceMongoDBCollection.find(filterArg);
const returnArray = []; const returnArray = [];
for (let item of foundDocs) { for (let item of foundDocs) {
@ -142,9 +142,7 @@ export class SmartDataDbDoc<T> {
/** /**
* deletes a document from the database * deletes a document from the database
*/ */
async delete() { async delete() {}
}
/** /**
* also store any referenced objects to DB * also store any referenced objects to DB