Compare commits

..

8 Commits

Author SHA1 Message Date
df02e5bb71 4.0.26 2021-11-12 19:16:11 +01:00
38e438c54f fix(core): update 2021-11-12 19:16:11 +01:00
11bc1ac6dc 4.0.25 2021-11-12 19:03:06 +01:00
3431e94ddd fix(core): update 2021-11-12 19:03:06 +01:00
739e040776 4.0.24 2021-11-12 19:02:29 +01:00
28d57efd9e fix(core): update 2021-11-12 19:02:29 +01:00
f50a61308c 4.0.23 2021-11-12 18:12:59 +01:00
42aa9f9f8a fix(core): update 2021-11-12 18:12:59 +01:00
9 changed files with 32 additions and 19 deletions

View File

@ -13,7 +13,6 @@ stages:
- metadata
before_script:
- apt-get update && apt-get install -y libcurl3 libssl-dev openssl libssl1.0.0 mongodb
- npm install -g @shipzone/npmci
# ====================

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@pushrocks/smartdata",
"version": "4.0.22",
"version": "4.0.26",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@pushrocks/smartdata",
"version": "4.0.22",
"version": "4.0.26",
"license": "MIT",
"dependencies": {
"@pushrocks/lik": "^5.0.0",

View File

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

View File

@ -53,7 +53,11 @@ tap.test('should create an easystore', async () => {
});
tap.test('close', async () => {
await mongod.stop();
if (mongod) {
await mongod.stop();
} else {
await testDb.mongoDb.dropDatabase();
}
await testDb.close();
});

View File

@ -202,7 +202,7 @@ tap.test('should store a new Truck', async () => {
tap.test('should use a cursor', async () => {
const cursor = await Truck.getCursor({});
cursor.forEach(async truckArg => {
cursor.forEach(async (truckArg) => {
console.log(truckArg.id);
});
});
@ -211,7 +211,11 @@ tap.test('should use a cursor', async () => {
// close the database connection
// =======================================
tap.test('close', async () => {
await mongod.stop();
if (mongod) {
await mongod.stop();
} else {
await testDb.mongoDb.dropDatabase();
}
await testDb.close();
});

View File

@ -93,7 +93,11 @@ tap.test('should get a car', async () => {
// close the database connection
// =======================================
tap.test('close', async () => {
await mongod.stop();
if (mongod) {
await mongod.stop();
} else {
await testDb.mongoDb.dropDatabase();
}
await testDb.close();
});

View File

@ -85,7 +85,7 @@ export function Manager<TManager extends IManager>(managerArg?: TManager | TDela
public static get manager() {
let manager: TManager;
if (!managerArg) {
manager = this.prototype.defaultManager
manager = this.prototype.defaultManager;
} else if (managerArg['db']) {
manager = managerArg as TManager;
} else {
@ -96,7 +96,7 @@ export function Manager<TManager extends IManager>(managerArg?: TManager | TDela
public get manager() {
let manager: TManager;
if (!managerArg) {
manager = this.defaultManager
manager = this.defaultManager;
} else if (managerArg['db']) {
manager = managerArg as TManager;
} else {
@ -171,7 +171,7 @@ export class SmartdataCollection<T> {
/**
* finds an object in the DbCollection
*/
public async findOne(filterObject: any): Promise<any> {
public async findOne(filterObject: any): Promise<any> {
await this.init();
const cursor = this.mongoDbCollection.find(filterObject);
const result = await cursor.next();

View File

@ -1,7 +1,7 @@
import * as plugins from './smartdata.plugins';
/**
* a wrapper for the native mongodb cursor. Exposes better
* a wrapper for the native mongodb cursor. Exposes better
*/
export class SmartdataDbCursor<T = any> {
// STATIC
@ -9,16 +9,16 @@ export class SmartdataDbCursor<T = any> {
// INSTANCE
public mongodbCursor: plugins.mongodb.FindCursor<T>;
constructor(cursorArg: plugins.mongodb.FindCursor<T>) {
this.mongodbCursor = cursorArg
};
this.mongodbCursor = cursorArg;
}
public async next(closeAtEnd = true) {
const result = await this.mongodbCursor.next();
if (!result && closeAtEnd) {
await this.close();
};
}
return result;
};
}
public async forEach(forEachFuncArg: (itemArg: T) => Promise<any>, closeCursorAtEnd = true) {
let currentValue: T;
@ -36,4 +36,4 @@ export class SmartdataDbCursor<T = any> {
public async close() {
await this.mongodbCursor.close();
}
}
}

View File

@ -165,7 +165,9 @@ export class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends
this: plugins.tsclass.typeFest.Class<T>,
filterArg: plugins.tsclass.typeFest.PartialDeep<T>
) {
const cursor: SmartdataDbCursor<T> = await (this as any).collection.getCursor(convertFilterForMongoDb(filterArg));
const cursor: SmartdataDbCursor<T> = await (this as any).collection.getCursor(
convertFilterForMongoDb(filterArg)
);
return cursor;
}
@ -179,7 +181,7 @@ export class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends
forEachFunction: (itemArg: T) => Promise<any>
) {
const cursor: SmartdataDbCursor<T> = await (this as any).getCursor(filterArg);
await cursor.forEach(forEachFunction)
await cursor.forEach(forEachFunction);
}
/**