fix(core): update
This commit is contained in:
parent
a739582861
commit
355a2a3f2b
1057
package-lock.json
generated
1057
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -7,9 +7,8 @@
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"testLocal": "(npmdocker)",
|
||||
"build": "(tsbuild --web)"
|
||||
"test": "tstest test/",
|
||||
"build": "tsbuild --web --allowimplicitany"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -23,8 +22,9 @@
|
||||
"homepage": "https://gitlab.com/pushrocks/smartdata#README",
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^5.0.4",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartlog": "^2.0.44",
|
||||
"@pushrocks/smartmongo": "^1.0.8",
|
||||
"@pushrocks/smartmongo": "^2.0.0",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartrx": "^2.0.25",
|
||||
"@pushrocks/smartstring": "^4.0.2",
|
||||
@ -40,7 +40,7 @@
|
||||
"@gitzone/tstest": "^1.0.71",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^17.0.33",
|
||||
"@types/node": "^17.0.34",
|
||||
"@types/shortid": "0.0.29"
|
||||
},
|
||||
"files": [
|
||||
|
@ -45,12 +45,11 @@ tap.test('should create an easystore', async () => {
|
||||
});
|
||||
|
||||
tap.test('close', async () => {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
await testDb.close();
|
||||
if (smartmongoInstance) {
|
||||
await smartmongoInstance.stop();
|
||||
} else {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
}
|
||||
await testDb.close();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
@ -205,12 +205,11 @@ tap.test('should use a cursor', async () => {
|
||||
// close the database connection
|
||||
// =======================================
|
||||
tap.test('close', async () => {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
await testDb.close();
|
||||
if (smartmongoInstance) {
|
||||
await smartmongoInstance.stop();
|
||||
} else {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
}
|
||||
await testDb.close();
|
||||
});
|
||||
|
||||
tap.start({ throwOnError: true });
|
||||
|
@ -85,12 +85,11 @@ tap.test('should get a car', async () => {
|
||||
// close the database connection
|
||||
// =======================================
|
||||
tap.test('close', async () => {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
await testDb.close();
|
||||
if (smartmongoInstance) {
|
||||
await smartmongoInstance.stop();
|
||||
} else {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
}
|
||||
await testDb.close();
|
||||
});
|
||||
|
||||
tap.start({ throwOnError: true });
|
||||
|
@ -19,14 +19,26 @@ let testDb: smartdata.SmartdataDb;
|
||||
|
||||
const totalCars = 2000;
|
||||
|
||||
tap.test('should create a testinstance as database', async () => {
|
||||
tap.skip.test('should create a testinstance as database', async () => {
|
||||
smartmongoInstance = await smartmongo.SmartMongo.createAndStart();
|
||||
testDb = new smartdata.SmartdataDb(await smartmongoInstance.getMongoDescriptor());
|
||||
await testDb.init();
|
||||
});
|
||||
|
||||
tap.test('should connect to atlas', async (tools) => {
|
||||
const databaseName = `test-smartdata-${smartunique.shortId()}`;
|
||||
testDb = new smartdata.SmartdataDb({
|
||||
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
|
||||
mongoDbName: databaseName,
|
||||
});
|
||||
await testDb.init();
|
||||
});
|
||||
|
||||
@smartdata.Collection(() => testDb)
|
||||
class House extends smartdata.SmartDataDbDoc<House, House> {
|
||||
@smartdata.unI()
|
||||
public id: string = smartunique.shortId();
|
||||
|
||||
@smartdata.svDb()
|
||||
public data = {
|
||||
id: smartunique.shortId(),
|
||||
@ -34,16 +46,17 @@ class House extends smartdata.SmartDataDbDoc<House, House> {
|
||||
}
|
||||
}
|
||||
|
||||
tap.skip.test('should watch a collection', async (toolsArg) => {
|
||||
tap.test('should watch a collection', async (toolsArg) => {
|
||||
const done = toolsArg.defer();
|
||||
const watcher = await House.watch({});
|
||||
watcher.changeSubject.subscribe(houseArg => {
|
||||
watcher.changeSubject.subscribe(async houseArg => {
|
||||
console.log('hey there, we observed a house');
|
||||
watcher.close();
|
||||
await watcher.close();
|
||||
done.resolve();
|
||||
});
|
||||
const newHouse = new House();
|
||||
await newHouse.save();
|
||||
console.log('saved a house');
|
||||
await done.promise;
|
||||
})
|
||||
|
||||
@ -51,12 +64,11 @@ tap.skip.test('should watch a collection', async (toolsArg) => {
|
||||
// close the database connection
|
||||
// =======================================
|
||||
tap.test('close', async () => {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
await testDb.close();
|
||||
if (smartmongoInstance) {
|
||||
await smartmongoInstance.stop();
|
||||
} else {
|
||||
await testDb.mongoDb.dropDatabase();
|
||||
}
|
||||
await testDb.close();
|
||||
});
|
||||
|
||||
tap.start({ throwOnError: true });
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartdata',
|
||||
version: '4.0.28',
|
||||
version: '4.0.29',
|
||||
description: 'do more with data'
|
||||
}
|
||||
|
@ -206,8 +206,12 @@ export class SmartdataCollection<T> {
|
||||
{
|
||||
$match: filterObject
|
||||
}
|
||||
]);
|
||||
return new SmartdataDbWatcher(changeStream);
|
||||
], {
|
||||
fullDocument: 'updateLookup'
|
||||
});
|
||||
const smartdataWatcher = new SmartdataDbWatcher(changeStream);
|
||||
await smartdataWatcher.readyDeferred.promise;
|
||||
return smartdataWatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,15 +5,19 @@ import * as plugins from './smartdata.plugins.js';
|
||||
*/
|
||||
export class SmartdataDbWatcher<T = any> {
|
||||
// STATIC
|
||||
public readyDeferred = plugins.smartpromise.defer();
|
||||
|
||||
// INSTANCE
|
||||
public changeStream: plugins.mongodb.ChangeStream<T>;
|
||||
public changeSubject = new plugins.smartrx.rxjs.Subject<T>();
|
||||
constructor(changeStreamArg: plugins.mongodb.ChangeStream<T>) {
|
||||
this.changeStream = changeStreamArg;
|
||||
this.changeStream.on('change', (item: T) => {
|
||||
this.changeStream.on('change', async (item: T) => {
|
||||
this.changeSubject.next(item);
|
||||
})
|
||||
plugins.smartdelay.delayFor(0).then(() => {
|
||||
this.readyDeferred.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
public async close() {
|
||||
|
@ -7,9 +7,11 @@ export { tsclass };
|
||||
import * as smartlog from '@pushrocks/smartlog';
|
||||
import * as lodash from 'lodash';
|
||||
import * as mongodb from 'mongodb';
|
||||
import * as smartdelay from '@pushrocks/smartdelay'
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartq from '@pushrocks/smartpromise';
|
||||
import * as smartrx from '@pushrocks/smartrx';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
|
||||
export { smartlog, lodash, smartq, smartrx, mongodb, smartstring, smartunique };
|
||||
export { smartdelay, smartpromise, smartlog, lodash, smartq, smartrx, mongodb, smartstring, smartunique };
|
||||
|
Loading…
Reference in New Issue
Block a user