Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
83a5170591 | |||
f94363cf31 | |||
df02e5bb71 | |||
38e438c54f | |||
11bc1ac6dc | |||
3431e94ddd | |||
739e040776 | |||
28d57efd9e |
@ -13,7 +13,6 @@ stages:
|
|||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update && apt-get install -y libcurl3 libssl-dev openssl libssl1.0.0 mongodb
|
|
||||||
- npm install -g @shipzone/npmci
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartdata",
|
"name": "@pushrocks/smartdata",
|
||||||
"version": "4.0.23",
|
"version": "4.0.27",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartdata",
|
"name": "@pushrocks/smartdata",
|
||||||
"version": "4.0.23",
|
"version": "4.0.27",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^5.0.0",
|
"@pushrocks/lik": "^5.0.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartdata",
|
"name": "@pushrocks/smartdata",
|
||||||
"version": "4.0.23",
|
"version": "4.0.27",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "do more with data",
|
"description": "do more with data",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -19,7 +19,7 @@ let testDb: smartdata.SmartdataDb;
|
|||||||
let smartdataOptions: smartdata.IMongoDescriptor;
|
let smartdataOptions: smartdata.IMongoDescriptor;
|
||||||
let mongod: mongoPlugin.MongoMemoryServer;
|
let mongod: mongoPlugin.MongoMemoryServer;
|
||||||
|
|
||||||
tap.skip.test('should create a testinstance as database', async () => {
|
tap.test('should create a testinstance as database', async () => {
|
||||||
mongod = await mongoPlugin.MongoMemoryServer.create();
|
mongod = await mongoPlugin.MongoMemoryServer.create();
|
||||||
console.log('created mongod instance');
|
console.log('created mongod instance');
|
||||||
console.log('mongod started');
|
console.log('mongod started');
|
||||||
@ -31,7 +31,7 @@ tap.skip.test('should create a testinstance as database', async () => {
|
|||||||
await testDb.init();
|
await testDb.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should connect to atlas', async (tools) => {
|
tap.skip.test('should connect to atlas', async (tools) => {
|
||||||
const databaseName = `test-smartdata-${smartunique.shortId()}`;
|
const databaseName = `test-smartdata-${smartunique.shortId()}`;
|
||||||
testDb = new smartdata.SmartdataDb({
|
testDb = new smartdata.SmartdataDb({
|
||||||
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
|
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
|
||||||
|
@ -21,7 +21,7 @@ let mongod: mongoPlugin.MongoMemoryServer;
|
|||||||
|
|
||||||
const totalCars = 2000;
|
const totalCars = 2000;
|
||||||
|
|
||||||
tap.skip.test('should create a testinstance as database', async () => {
|
tap.test('should create a testinstance as database', async () => {
|
||||||
mongod = await mongoPlugin.MongoMemoryServer.create();
|
mongod = await mongoPlugin.MongoMemoryServer.create();
|
||||||
console.log('created mongod instance');
|
console.log('created mongod instance');
|
||||||
console.log('mongod started');
|
console.log('mongod started');
|
||||||
@ -33,7 +33,7 @@ tap.skip.test('should create a testinstance as database', async () => {
|
|||||||
await testDb.init();
|
await testDb.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should connect to atlas', async (tools) => {
|
tap.skip.test('should connect to atlas', async (tools) => {
|
||||||
const databaseName = `test-smartdata-${smartunique.shortId()}`;
|
const databaseName = `test-smartdata-${smartunique.shortId()}`;
|
||||||
testDb = new smartdata.SmartdataDb({
|
testDb = new smartdata.SmartdataDb({
|
||||||
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
|
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
|
||||||
@ -202,7 +202,7 @@ tap.test('should store a new Truck', async () => {
|
|||||||
|
|
||||||
tap.test('should use a cursor', async () => {
|
tap.test('should use a cursor', async () => {
|
||||||
const cursor = await Truck.getCursor({});
|
const cursor = await Truck.getCursor({});
|
||||||
cursor.forEach(async truckArg => {
|
cursor.forEach(async (truckArg) => {
|
||||||
console.log(truckArg.id);
|
console.log(truckArg.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ let mongod: mongoPlugin.MongoMemoryServer;
|
|||||||
|
|
||||||
const totalCars = 2000;
|
const totalCars = 2000;
|
||||||
|
|
||||||
tap.skip.test('should create a testinstance as database', async () => {
|
tap.test('should create a testinstance as database', async () => {
|
||||||
mongod = await mongoPlugin.MongoMemoryServer.create();
|
mongod = await mongoPlugin.MongoMemoryServer.create();
|
||||||
console.log('created mongod instance');
|
console.log('created mongod instance');
|
||||||
console.log('mongod started');
|
console.log('mongod started');
|
||||||
@ -33,7 +33,7 @@ tap.skip.test('should create a testinstance as database', async () => {
|
|||||||
await testDb.init();
|
await testDb.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should connect to atlas', async (tools) => {
|
tap.skip.test('should connect to atlas', async (tools) => {
|
||||||
const databaseName = `test-smartdata-${smartunique.shortId()}`;
|
const databaseName = `test-smartdata-${smartunique.shortId()}`;
|
||||||
testDb = new smartdata.SmartdataDb({
|
testDb = new smartdata.SmartdataDb({
|
||||||
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
|
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
|
||||||
|
@ -2,5 +2,6 @@ export * from './smartdata.classes.db';
|
|||||||
export * from './smartdata.classes.collection';
|
export * from './smartdata.classes.collection';
|
||||||
export * from './smartdata.classes.doc';
|
export * from './smartdata.classes.doc';
|
||||||
export * from './smartdata.classes.easystore';
|
export * from './smartdata.classes.easystore';
|
||||||
|
export * from './smartdata.classes.cursor';
|
||||||
|
|
||||||
export { IMongoDescriptor } from './interfaces';
|
export { IMongoDescriptor } from './interfaces';
|
||||||
|
@ -85,7 +85,7 @@ export function Manager<TManager extends IManager>(managerArg?: TManager | TDela
|
|||||||
public static get manager() {
|
public static get manager() {
|
||||||
let manager: TManager;
|
let manager: TManager;
|
||||||
if (!managerArg) {
|
if (!managerArg) {
|
||||||
manager = this.prototype.defaultManager
|
manager = this.prototype.defaultManager;
|
||||||
} else if (managerArg['db']) {
|
} else if (managerArg['db']) {
|
||||||
manager = managerArg as TManager;
|
manager = managerArg as TManager;
|
||||||
} else {
|
} else {
|
||||||
@ -96,7 +96,7 @@ export function Manager<TManager extends IManager>(managerArg?: TManager | TDela
|
|||||||
public get manager() {
|
public get manager() {
|
||||||
let manager: TManager;
|
let manager: TManager;
|
||||||
if (!managerArg) {
|
if (!managerArg) {
|
||||||
manager = this.defaultManager
|
manager = this.defaultManager;
|
||||||
} else if (managerArg['db']) {
|
} else if (managerArg['db']) {
|
||||||
manager = managerArg as TManager;
|
manager = managerArg as TManager;
|
||||||
} else {
|
} else {
|
||||||
@ -171,7 +171,7 @@ export class SmartdataCollection<T> {
|
|||||||
/**
|
/**
|
||||||
* finds an object in the DbCollection
|
* finds an object in the DbCollection
|
||||||
*/
|
*/
|
||||||
public async findOne(filterObject: any): Promise<any> {
|
public async findOne(filterObject: any): Promise<any> {
|
||||||
await this.init();
|
await this.init();
|
||||||
const cursor = this.mongoDbCollection.find(filterObject);
|
const cursor = this.mongoDbCollection.find(filterObject);
|
||||||
const result = await cursor.next();
|
const result = await cursor.next();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as plugins from './smartdata.plugins';
|
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> {
|
export class SmartdataDbCursor<T = any> {
|
||||||
// STATIC
|
// STATIC
|
||||||
@ -9,16 +9,16 @@ export class SmartdataDbCursor<T = any> {
|
|||||||
// INSTANCE
|
// INSTANCE
|
||||||
public mongodbCursor: plugins.mongodb.FindCursor<T>;
|
public mongodbCursor: plugins.mongodb.FindCursor<T>;
|
||||||
constructor(cursorArg: plugins.mongodb.FindCursor<T>) {
|
constructor(cursorArg: plugins.mongodb.FindCursor<T>) {
|
||||||
this.mongodbCursor = cursorArg
|
this.mongodbCursor = cursorArg;
|
||||||
};
|
}
|
||||||
|
|
||||||
public async next(closeAtEnd = true) {
|
public async next(closeAtEnd = true) {
|
||||||
const result = await this.mongodbCursor.next();
|
const result = await this.mongodbCursor.next();
|
||||||
if (!result && closeAtEnd) {
|
if (!result && closeAtEnd) {
|
||||||
await this.close();
|
await this.close();
|
||||||
};
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
|
||||||
public async forEach(forEachFuncArg: (itemArg: T) => Promise<any>, closeCursorAtEnd = true) {
|
public async forEach(forEachFuncArg: (itemArg: T) => Promise<any>, closeCursorAtEnd = true) {
|
||||||
let currentValue: T;
|
let currentValue: T;
|
||||||
@ -36,4 +36,4 @@ export class SmartdataDbCursor<T = any> {
|
|||||||
public async close() {
|
public async close() {
|
||||||
await this.mongodbCursor.close();
|
await this.mongodbCursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,9 @@ export class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends
|
|||||||
this: plugins.tsclass.typeFest.Class<T>,
|
this: plugins.tsclass.typeFest.Class<T>,
|
||||||
filterArg: plugins.tsclass.typeFest.PartialDeep<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;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +181,7 @@ export class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends
|
|||||||
forEachFunction: (itemArg: T) => Promise<any>
|
forEachFunction: (itemArg: T) => Promise<any>
|
||||||
) {
|
) {
|
||||||
const cursor: SmartdataDbCursor<T> = await (this as any).getCursor(filterArg);
|
const cursor: SmartdataDbCursor<T> = await (this as any).getCursor(filterArg);
|
||||||
await cursor.forEach(forEachFunction)
|
await cursor.forEach(forEachFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user