fix(core): update

This commit is contained in:
2022-06-06 13:04:30 +02:00
parent 82d970069b
commit 32d3ea4d65
10 changed files with 56 additions and 11 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/mongodump',
version: '1.0.2',
version: '1.0.3',
description: 'a tool to handle dumps of mongodb databases'
}

View File

@ -1,2 +1,3 @@
export * from './mongodb.classes.mongodump.js';
export * from './mongodb.classes.mongodumptarget.js';
export * from './mongodump.classes.mongodump.js';
export * from './mongodump.classes.mongodumptarget.js';

View File

@ -6,5 +6,5 @@ import * as plugins from './mongodump.plugins.js';
*
*/
export class MongoCompressedDump {
}
}

View File

@ -1,5 +1,5 @@
import * as plugins from './mongodump.plugins.js';
import { MongoDumpTarget } from './mongodb.classes.mongodumptarget.js';
import { MongoDumpTarget } from './mongodump.classes.mongodumptarget.js';
export class MongoDump {
public mongoTargetObjectMap = new plugins.lik.ObjectMap<MongoDumpTarget>();

View File

@ -61,8 +61,16 @@ export class MongoDumpTarget {
/**
* dumps a collection to a directory
*/
public async dumpCollectionToDir(collectionArg: plugins.mongodb.Collection, dirArg: string) {
public async dumpCollectionToDir(collectionArg: plugins.mongodb.Collection, dirArg: string, nameTransformFunction = (doc: any) => doc._id) {
const dirPath = plugins.smartpath.transform.makeAbsolute(dirArg);
const collectionDir = plugins.path.join(dirPath, collectionArg.collectionName);
await plugins.smartfile.fs.ensureDir(collectionDir);
const cursor = collectionArg.find();
let value = await cursor.next();
while(value) {
await plugins.smartfile.memory.toFs(JSON.stringify(value, null, 2), plugins.path.join(collectionDir, `${nameTransformFunction(value)}.json`));
value = await cursor.next();
}
}
public async dumpCollectionToTarArchive(collectionArg: plugins.mongodb.Collection) {}

View File

@ -1,11 +1,22 @@
// node native
import * as path from 'path';
export {
path
}
// pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartfile from '@pushrocks/smartfile';
import * as smartjson from '@pushrocks/smartjson';
import * as smartpath from '@pushrocks/smartpath';
import * as smartpromise from '@pushrocks/smartpromise';
export {
lik,
smartfile,
smartjson,
smartpath,
smartpromise
}