fix(core): update
This commit is contained in:
@ -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'
|
||||
}
|
||||
|
@ -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';
|
||||
|
||||
|
@ -6,5 +6,5 @@ import * as plugins from './mongodump.plugins.js';
|
||||
*
|
||||
*/
|
||||
export class MongoCompressedDump {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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>();
|
@ -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) {}
|
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user