fix(core): update
This commit is contained in:
parent
82d970069b
commit
32d3ea4d65
6
package-lock.json
generated
6
package-lock.json
generated
@ -11,6 +11,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^6.0.0",
|
"@pushrocks/lik": "^6.0.0",
|
||||||
"@pushrocks/smartfile": "^9.0.6",
|
"@pushrocks/smartfile": "^9.0.6",
|
||||||
|
"@pushrocks/smartjson": "^4.0.6",
|
||||||
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@pushrocks/smartpromise": "^3.1.7",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@tsclass/tsclass": "^4.0.3",
|
"@tsclass/tsclass": "^4.0.3",
|
||||||
"mongodb": "^4.6.0"
|
"mongodb": "^4.6.0"
|
||||||
@ -686,7 +688,6 @@
|
|||||||
"version": "5.0.5",
|
"version": "5.0.5",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpath/-/smartpath-5.0.5.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpath/-/smartpath-5.0.5.tgz",
|
||||||
"integrity": "sha512-t2lXXGMpKnPlwubIcYGD6cGi2CUJxJ3t2yftVt8tHfjX68jELA5sJhFMtyD3AeFZVxePFZOCiHwWEbWkSDNnmw==",
|
"integrity": "sha512-t2lXXGMpKnPlwubIcYGD6cGi2CUJxJ3t2yftVt8tHfjX68jELA5sJhFMtyD3AeFZVxePFZOCiHwWEbWkSDNnmw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@pushrocks/smartpdf": {
|
"node_modules/@pushrocks/smartpdf": {
|
||||||
@ -6944,8 +6945,7 @@
|
|||||||
"@pushrocks/smartpath": {
|
"@pushrocks/smartpath": {
|
||||||
"version": "5.0.5",
|
"version": "5.0.5",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpath/-/smartpath-5.0.5.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpath/-/smartpath-5.0.5.tgz",
|
||||||
"integrity": "sha512-t2lXXGMpKnPlwubIcYGD6cGi2CUJxJ3t2yftVt8tHfjX68jELA5sJhFMtyD3AeFZVxePFZOCiHwWEbWkSDNnmw==",
|
"integrity": "sha512-t2lXXGMpKnPlwubIcYGD6cGi2CUJxJ3t2yftVt8tHfjX68jELA5sJhFMtyD3AeFZVxePFZOCiHwWEbWkSDNnmw=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@pushrocks/smartpdf": {
|
"@pushrocks/smartpdf": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^6.0.0",
|
"@pushrocks/lik": "^6.0.0",
|
||||||
"@pushrocks/smartfile": "^9.0.6",
|
"@pushrocks/smartfile": "^9.0.6",
|
||||||
|
"@pushrocks/smartjson": "^4.0.6",
|
||||||
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@pushrocks/smartpromise": "^3.1.7",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@tsclass/tsclass": "^4.0.3",
|
"@tsclass/tsclass": "^4.0.3",
|
||||||
"mongodb": "^4.6.0"
|
"mongodb": "^4.6.0"
|
||||||
|
@ -24,9 +24,24 @@ export const generateTestData = async (mongoDescriptorArg: smartdata.IMongoDescr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@smartdata.Collection(db)
|
||||||
|
class Truck extends smartdata.SmartDataDbDoc<Truck, Truck> {
|
||||||
|
@smartdata.unI()
|
||||||
|
id = `hello-${counter}`;
|
||||||
|
|
||||||
|
@smartdata.svDb()
|
||||||
|
data = {
|
||||||
|
'some' : {
|
||||||
|
'complex': 'structure'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (counter < 100) {
|
while (counter < 100) {
|
||||||
const house = new House();
|
const house = new House();
|
||||||
await house.save();
|
await house.save();
|
||||||
|
const truck = new Truck();
|
||||||
|
await truck.save();
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,14 @@ tap.test('should deploy sample data', async () => {
|
|||||||
tap.test('should add a mongotarget to mongodump instance', async () => {
|
tap.test('should add a mongotarget to mongodump instance', async () => {
|
||||||
const target = await testMongodump.addMongoTargetByMongoDescriptor(await testSmartMongo.getMongoDescriptor());
|
const target = await testMongodump.addMongoTargetByMongoDescriptor(await testSmartMongo.getMongoDescriptor());
|
||||||
await target.getCollections();
|
await target.getCollections();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should dump a collection to a directory', async () => {
|
||||||
|
const target = await testMongodump.addMongoTargetByMongoDescriptor(await testSmartMongo.getMongoDescriptor());
|
||||||
|
const collections = await target.getCollections();
|
||||||
|
for (const collection of collections) {
|
||||||
|
await target.dumpCollectionToDir(collection, '.nogit', doc => doc.id);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
tap.test('should stop the smartmongo instance', async () => {
|
tap.test('should stop the smartmongo instance', async () => {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/mongodump',
|
name: '@pushrocks/mongodump',
|
||||||
version: '1.0.2',
|
version: '1.0.3',
|
||||||
description: 'a tool to handle dumps of mongodb databases'
|
description: 'a tool to handle dumps of mongodb databases'
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export * from './mongodb.classes.mongodump.js';
|
export * from './mongodump.classes.mongodump.js';
|
||||||
export * from './mongodb.classes.mongodumptarget.js';
|
export * from './mongodump.classes.mongodumptarget.js';
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './mongodump.plugins.js';
|
import * as plugins from './mongodump.plugins.js';
|
||||||
import { MongoDumpTarget } from './mongodb.classes.mongodumptarget.js';
|
import { MongoDumpTarget } from './mongodump.classes.mongodumptarget.js';
|
||||||
|
|
||||||
export class MongoDump {
|
export class MongoDump {
|
||||||
public mongoTargetObjectMap = new plugins.lik.ObjectMap<MongoDumpTarget>();
|
public mongoTargetObjectMap = new plugins.lik.ObjectMap<MongoDumpTarget>();
|
@ -61,8 +61,16 @@ export class MongoDumpTarget {
|
|||||||
/**
|
/**
|
||||||
* dumps a collection to a directory
|
* 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) {}
|
public async dumpCollectionToTarArchive(collectionArg: plugins.mongodb.Collection) {}
|
@ -1,11 +1,22 @@
|
|||||||
|
// node native
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export {
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as lik from '@pushrocks/lik';
|
import * as lik from '@pushrocks/lik';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
|
import * as smartjson from '@pushrocks/smartjson';
|
||||||
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
lik,
|
lik,
|
||||||
smartfile,
|
smartfile,
|
||||||
|
smartjson,
|
||||||
|
smartpath,
|
||||||
smartpromise
|
smartpromise
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user