mongoplusplus 1.0.4 → 1.0.5

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/package.json CHANGED
@@ -1,41 +1,54 @@
1
- {
2
- "name": "mongoplusplus",
3
- "version": "1.0.4",
4
- "description": "load balancing of read and write operations across multiple MongoDB servers ",
5
- "main": "mongoplus.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "author": "somen das(somen6562@gmail.com)",
10
- "keywords": [
11
- "MongoDB",
12
- "Database",
13
- "ORM",
14
- "Wrapper",
15
- "Mongoose",
16
- "Multi-Database",
17
- "Data Management",
18
- "Async Operations",
19
- "Scalable",
20
- "Readability",
21
- "Performance",
22
- "Node.js",
23
- "Worker Threads",
24
- "Connection Pooling",
25
- "Schema Management",
26
- "CRUD Operations",
27
- "Document-Oriented",
28
- "Distributed",
29
- "Replication",
30
- "Sharding",
31
- "load balancing",
32
- "multiple database",
33
- "Aggregation Framework"
34
- ],
35
- "license": "ISC",
36
- "dependencies": {
37
- "mongoose": "^6.3.5",
38
- "mongoose-sequence": "^5.3.1",
39
- "mongoplusplus": "^1.0.1"
40
- }
41
- }
1
+ {
2
+ "name": "mongoplusplus",
3
+ "version": "1.0.5",
4
+ "description": "load balancing of read and write operations across multiple MongoDB servers ",
5
+ "main": "mongoplus.js",
6
+ "types": "index.d.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/KTBsomen/mongoplusplus.git"
13
+ },
14
+ "author": "somen das(somen6562@gmail.com)",
15
+ "keywords": [
16
+ "MongoDB",
17
+ "Database",
18
+ "ORM",
19
+ "Wrapper",
20
+ "Mongoose",
21
+ "Multi-Database",
22
+ "Data Management",
23
+ "Async Operations",
24
+ "Scalable",
25
+ "Readability",
26
+ "Performance",
27
+ "Node.js",
28
+ "Worker Threads",
29
+ "Connection Pooling",
30
+ "Schema Management",
31
+ "CRUD Operations",
32
+ "Document-Oriented",
33
+ "Distributed",
34
+ "Replication",
35
+ "Sharding",
36
+ "load balancing",
37
+ "multiple database",
38
+ "Aggregation Framework",
39
+ "Indexing",
40
+ "Transactions",
41
+ "Database Orchestration",
42
+ "High Availability",
43
+ "Distributed database"
44
+ ],
45
+ "license": "ISC",
46
+ "dependencies": {
47
+ "mongoose": "^6.13.8",
48
+ "mongoose-sequence": "^5.3.1"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^24.10.1",
52
+ "typescript": "^5.9.3"
53
+ }
54
+ }
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,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2019",
4
+ "module": "CommonJS",
5
+ "strict": true,
6
+ "esModuleInterop": true,
7
+ "skipLibCheck": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "types": [
10
+ "node"
11
+ ]
12
+ },
13
+ "include": [
14
+ "**/*.ts"
15
+ ],
16
+ "exclude": [
17
+ "node_modules",
18
+ ]
19
+ }