mongoplusplus 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -169
- package/index.d.ts +226 -0
- package/mongoplus.js +486 -320
- package/package.json +62 -41
- package/test.js +57 -0
- package/tsconfig.json +20 -0
package/package.json
CHANGED
|
@@ -1,41 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mongoplusplus",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "load balancing of read and write operations across multiple MongoDB servers ",
|
|
5
|
-
"main": "mongoplus.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "mongoplusplus",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "load balancing of read and write operations across multiple MongoDB servers ",
|
|
5
|
+
"main": "mongoplus.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/KTBsomen/mongoplusplus.git"
|
|
14
|
+
},
|
|
15
|
+
"author": "somen das(somen6562@gmail.com)",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"MongoDB",
|
|
18
|
+
"Database",
|
|
19
|
+
"ORM",
|
|
20
|
+
"Wrapper",
|
|
21
|
+
"Mongoose",
|
|
22
|
+
"Multi-Database",
|
|
23
|
+
"Data Management",
|
|
24
|
+
"Async Operations",
|
|
25
|
+
"Scalable",
|
|
26
|
+
"Readability",
|
|
27
|
+
"Performance",
|
|
28
|
+
"Node.js",
|
|
29
|
+
"Worker Threads",
|
|
30
|
+
"Connection Pooling",
|
|
31
|
+
"Schema Management",
|
|
32
|
+
"CRUD Operations",
|
|
33
|
+
"Document-Oriented",
|
|
34
|
+
"Distributed",
|
|
35
|
+
"Replication",
|
|
36
|
+
"Sharding",
|
|
37
|
+
"load balancing",
|
|
38
|
+
"multiple database",
|
|
39
|
+
"Aggregation Framework",
|
|
40
|
+
"Indexing",
|
|
41
|
+
"Transactions",
|
|
42
|
+
"Database Orchestration",
|
|
43
|
+
"High Availability",
|
|
44
|
+
"Distributed database"
|
|
45
|
+
],
|
|
46
|
+
"license": "ISC",
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"mongoose": "^6.13.8",
|
|
49
|
+
"mongoose-sequence": "^5.3.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^24.10.1",
|
|
53
|
+
"typescript": "^5.9.3"
|
|
54
|
+
},
|
|
55
|
+
"exports": {
|
|
56
|
+
".": {
|
|
57
|
+
"require": "./mongoplus.js",
|
|
58
|
+
"default": "./mongoplus.js"
|
|
59
|
+
},
|
|
60
|
+
"./package.json": "./package.json"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/test.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
const Mongoplus = require('./mongoplus'); // Hypothetical library
|
|
3
|
+
// Performance comparison example
|
|
4
|
+
async function performanceComparison() {
|
|
5
|
+
const mongoplus = new Mongoplus([
|
|
6
|
+
'mongodb+srv://xxxxxxxxxxxxxxxxxxxxxxxxxx/testbulkwrite?retryWrites=true&w=majority',
|
|
7
|
+
'mongodb+srv://xxxxxxxxxxxxxxxxxxxxxxxxxx/testbulkwrite?retryWrites=true&w=majority',
|
|
8
|
+
'readonly:mongodb+srv://xxxxxxxxxxxxxxxxx/testbulkwrite?retryWrites=true&w=majority'
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
await mongoplus.connectToAll();
|
|
12
|
+
|
|
13
|
+
const schema = mongoplus.Schema({
|
|
14
|
+
name: String,
|
|
15
|
+
email: String,
|
|
16
|
+
age: Number,
|
|
17
|
+
dbIndex: { type: Number, required: true }
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const UserModel = mongoplus.buildModel('UserBulkWrite', schema);
|
|
21
|
+
const testData = Array.from({ length: 10000 }, (_, i) => ({
|
|
22
|
+
name: `User ${i}`,
|
|
23
|
+
email: `user${i}@example.com`,
|
|
24
|
+
age: 20 + (i % 50)
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
// Test 1: Large batch, concurrent
|
|
28
|
+
console.time('Large batch concurrent');
|
|
29
|
+
await UserModel.bulkWrite(testData, {
|
|
30
|
+
batchSize: 5000,
|
|
31
|
+
concurrentBatches: true
|
|
32
|
+
});
|
|
33
|
+
console.timeEnd('Large batch concurrent');
|
|
34
|
+
|
|
35
|
+
// Test 2: Small batch, concurrent
|
|
36
|
+
console.time('Small batch concurrent');
|
|
37
|
+
await UserModel.bulkWrite(testData, {
|
|
38
|
+
batchSize: 500,
|
|
39
|
+
concurrentBatches: true
|
|
40
|
+
});
|
|
41
|
+
console.timeEnd('Small batch concurrent');
|
|
42
|
+
|
|
43
|
+
// Test 3: Small batch, sequential
|
|
44
|
+
console.time('Small batch sequential');
|
|
45
|
+
await UserModel.bulkWrite(testData, {
|
|
46
|
+
batchSize: 500,
|
|
47
|
+
concurrentBatches: false
|
|
48
|
+
});
|
|
49
|
+
console.timeEnd('Small batch sequential');
|
|
50
|
+
}
|
|
51
|
+
performanceComparison().then(() => {
|
|
52
|
+
console.log('Performance comparison completed.');
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}).catch(err => {
|
|
55
|
+
console.error('Error during performance comparison:', err);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2019",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"types": [
|
|
11
|
+
"node"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"include": [
|
|
15
|
+
"**/*.ts"
|
|
16
|
+
],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules",
|
|
19
|
+
]
|
|
20
|
+
}
|