update structure
This commit is contained in:
parent
50a6a1a690
commit
411b0b1ae9
12
dist/smartdata.classes.dbcollection.d.ts
vendored
12
dist/smartdata.classes.dbcollection.d.ts
vendored
@ -6,13 +6,17 @@ export declare class DbCollection<T> {
|
||||
/**
|
||||
* adds a validation function that all newly inserted and updated objects have to pass
|
||||
*/
|
||||
addObjectValidation(): void;
|
||||
addObjectValidation(funcArg: any): void;
|
||||
/**
|
||||
* inserts am object into the DbCollection
|
||||
* finds an object in the DbCollection
|
||||
*/
|
||||
insert(objectArg: T): void;
|
||||
find(docMatchArg: T): T[];
|
||||
/**
|
||||
* inserts object into the DbCollection
|
||||
*/
|
||||
insertOne(docArg: T): PromiseLike<void>;
|
||||
/**
|
||||
* inserts many objects at once into the DbCollection
|
||||
*/
|
||||
insertMany(objectArrayArg: T[]): void;
|
||||
insertMany(docArrayArg: T[]): void;
|
||||
}
|
||||
|
19
dist/smartdata.classes.dbcollection.js
vendored
19
dist/smartdata.classes.dbcollection.js
vendored
@ -6,15 +6,24 @@ class DbCollection {
|
||||
/**
|
||||
* adds a validation function that all newly inserted and updated objects have to pass
|
||||
*/
|
||||
addObjectValidation() { }
|
||||
addObjectValidation(funcArg) { }
|
||||
/**
|
||||
* inserts am object into the DbCollection
|
||||
* finds an object in the DbCollection
|
||||
*/
|
||||
insert(objectArg) { }
|
||||
find(docMatchArg) {
|
||||
return this.collection.find().toArray();
|
||||
}
|
||||
/**
|
||||
* inserts object into the DbCollection
|
||||
*/
|
||||
insertOne(docArg) {
|
||||
return this.collection.insertOne(docArg);
|
||||
}
|
||||
/**
|
||||
* inserts many objects at once into the DbCollection
|
||||
*/
|
||||
insertMany(objectArrayArg) { }
|
||||
insertMany(docArrayArg) {
|
||||
}
|
||||
}
|
||||
exports.DbCollection = DbCollection;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRkYXRhLmNsYXNzZXMuZGJjb2xsZWN0aW9uLmpzIiwic291cmNlUm9v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FRDs7T0FFRztJQUNILFNBQVMsQ0FBQyxNQUFTO1FBQ2YsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQzVDLENBQUM7SUFFRDs7T0FFRztJQUNILFVBQVUsQ0FBQyxXQUFnQjtJQUUzQixDQUFDO0FBQ0wsQ0FBQztBQS9CWSxvQkFBWSxlQStCeEIsQ0FBQSJ9
|
@ -5,7 +5,8 @@
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(npm run prepareMongo && npmts)",
|
||||
"prepareMongo": "(rm -rf ./test/data && mkdir ./test/data/)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -30,6 +31,7 @@
|
||||
"@types/should": "^8.1.29",
|
||||
"shelljs": "^0.7.4",
|
||||
"should": "^11.1.0",
|
||||
"smartstring": "^2.0.17",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
require('typings-test');
|
||||
let portastic = require('portastic');
|
||||
const shelljs = require('shelljs');
|
||||
const smartstring = require('smartstring');
|
||||
// the tested module
|
||||
const smartdata = require('../dist/index');
|
||||
let mongoChildProcess;
|
||||
@ -13,7 +13,7 @@ describe('mongodb', function () {
|
||||
mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017', { async: true, silent: true });
|
||||
let doneCalled = false;
|
||||
mongoChildProcess.stdout.on('data', function (data) {
|
||||
console.log(data);
|
||||
console.log(smartstring.indent.indentWithPrefix(data, "*** MongoDB Process *** : "));
|
||||
if (!doneCalled) {
|
||||
if (/waiting for connections on port 27017/.test(data)) {
|
||||
doneCalled = true;
|
||||
@ -31,6 +31,9 @@ describe('smartdata', function () {
|
||||
it('should create a collection', function () {
|
||||
testDbCollection = new smartdata.DbCollection('something', testDbConnection);
|
||||
});
|
||||
it('should insert something into the collection', function () {
|
||||
testDbCollection.insertOne({ hello: 'test' });
|
||||
});
|
||||
it('should close the db Connection', function () {
|
||||
testDbConnection.close();
|
||||
});
|
||||
@ -42,4 +45,4 @@ describe('mongodb', function () {
|
||||
mongoChildProcess.kill('SIGTERM');
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLElBQUksU0FBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQTtBQUNwQyxNQUFZLE9BQU8sV0FBTSxTQUd6QixDQUFDLENBSGlDO0FBRWxDLG9CQUFvQjtBQUNwQixNQUFZLFNBQVMsV0FBTSxlQUUzQixDQUFDLENBRnlDO0FBRTFDLElBQUksaUJBQWlCLENBQUE7QUFDckIsSUFBSSxnQkFBd0MsQ0FBQTtBQUM1QyxJQUFJLGdCQUE2QyxDQUFBO0FBRWpELFFBQVEsQ0FBQyxTQUFTLEVBQUU7SUFDaEIsRUFBRSxDQUFDLHNCQUFzQixFQUFFLFVBQVUsSUFBSTtRQUNyQyxJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO1FBQ25CLGlCQUFpQixHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsMENBQTBDLEVBQUUsRUFBRSxLQUFLLEVBQUUsSUFBSSxFQUFFLE1BQU0sRUFBRSxJQUFJLEVBQUUsQ0FBQyxDQUFBO1FBQzNHLElBQUksVUFBVSxHQUFHLEtBQUssQ0FBQTtRQUN0QixpQkFBaUIsQ0FBQyxNQUFNLENBQUMsRUFBRSxDQUFDLE1BQU0sRUFBRSxVQUFTLElBQUk7WUFDN0MsT0FBTyxDQUFDLEdBQU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DLENBQUMsQ0FBQTtJQUMvQyxDQUFDLENBQUMsQ0FBQTtJQUNGLEVBQUUsQ0FBQyxnQ0FBZ0MsRUFBRTtRQUNqQyxnQkFBZ0IsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUM1QixDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFBO0FBRUYsUUFBUSxDQUFDLFNBQVMsRUFBRTtJQUNoQixFQUFFLENBQUMscUJBQXFCLEVBQUU7UUFDdEIsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQTtRQUNuQixPQUFPLENBQUMsSUFBSSxDQUFDLHdDQUF3QyxDQUFDLENBQUE7UUFDdEQsaUJBQWlCLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFBO0lBQ3JDLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==
|
@ -2,6 +2,7 @@ import 'typings-test'
|
||||
|
||||
import * as shelljs from 'shelljs'
|
||||
import * as should from 'should'
|
||||
import * as smartstring from 'smartstring'
|
||||
|
||||
// the tested module
|
||||
import * as smartdata from '../dist/index'
|
||||
@ -16,7 +17,7 @@ describe('mongodb', function () {
|
||||
mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017', { async: true, silent: true })
|
||||
let doneCalled = false
|
||||
mongoChildProcess.stdout.on('data', function(data) {
|
||||
console.log(data)
|
||||
console.log(smartstring.indent.indentWithPrefix(data,"*** MongoDB Process *** : "))
|
||||
if (!doneCalled){
|
||||
if (/waiting for connections on port 27017/.test(data)) {
|
||||
doneCalled = true
|
||||
@ -34,6 +35,10 @@ describe('smartdata', function () {
|
||||
it('should create a collection', function () {
|
||||
testDbCollection = new smartdata.DbCollection('something', testDbConnection)
|
||||
})
|
||||
it('should insert something into the collection',function(done){
|
||||
testDbCollection.insertOne({hello: 'test'}).then(() => { done() })
|
||||
})
|
||||
it('should find all instances of test')
|
||||
it('should close the db Connection', function () {
|
||||
testDbConnection.close()
|
||||
})
|
||||
|
@ -10,15 +10,26 @@ export class DbCollection<T> {
|
||||
/**
|
||||
* adds a validation function that all newly inserted and updated objects have to pass
|
||||
*/
|
||||
addObjectValidation(){}
|
||||
addObjectValidation(funcArg){}
|
||||
|
||||
/**
|
||||
* inserts am object into the DbCollection
|
||||
* finds an object in the DbCollection
|
||||
*/
|
||||
insert(objectArg: T) {}
|
||||
find(docMatchArg: T): T[] {
|
||||
return this.collection.find().toArray()
|
||||
}
|
||||
|
||||
/**
|
||||
* inserts object into the DbCollection
|
||||
*/
|
||||
insertOne(docArg: T): PromiseLike<void> {
|
||||
return this.collection.insertOne(docArg)
|
||||
}
|
||||
|
||||
/**
|
||||
* inserts many objects at once into the DbCollection
|
||||
*/
|
||||
insertMany(objectArrayArg: T[]) {}
|
||||
insertMany(docArrayArg: T[]): void {
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user