multi-db-orm 2.1.6 → 2.1.7

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/backup.js CHANGED
@@ -1,108 +1,108 @@
1
- var fs = require('fs');
2
- const { stringify } = require('querystring');
3
- async function log(arg) {
4
- update(arg)
5
- }
6
- var maxC = 0;
7
- var curC = 1;
8
- async function processCollection(n) {
9
-
10
- var coll = db.collection(n.name)
11
- var count = await coll.countDocuments()
12
- log(n.name + " = " + count);
13
- await coll.find()
14
- .toArray((err, results) => {
15
- if (err) throw err;
16
-
17
- output[n.name] = results;
18
- log("Dumped " + n.name + " (" + curC + "/" + maxC + ")");
19
- if (maxC > curC) {
20
- curC++;
21
- }
22
- else {
23
- log("\n\n All Dumps completed !!");
24
- log("Saving to file.... ", file)
25
- write();
26
- }
27
- })
28
- };
29
-
30
- async function write(skipWriteToFile) {
31
- var blob=JSON.stringify(output);
32
- if (skipWriteToFile !== true) {
33
-
34
- if(!fs.existsSync('./dumps'))
35
- fs.mkdirSync('./dumps')
36
- fs.writeFileSync(file, blob);
37
-
38
- }
39
- finish("Done !", blob);
40
- }
41
-
42
- function getDateString() {
43
- var d = new Date();
44
-
45
- var datestring = d.getFullYear() + "" + (d.getMonth() + 1) + "" + d.getDate() + "_" +
46
- d.getHours() + "" + d.getMinutes();
47
-
48
- return datestring;
49
- }
50
-
51
- var output = {};
52
- var file;
53
- var db;
54
- async function dump() {
55
- file = "dumps/dump_" + getDateString() + ".json";
56
- if(OVERRIDE_FILE){
57
- file=OVERRIDE_FILE;
58
- }
59
- log("Dumps Saved to " + file);
60
- db.listCollections().toArray(function (err, names) {
61
-
62
- maxC = names.length;
63
- names.forEach(processCollection)
64
- });
65
-
66
- }
67
-
68
- var update;
69
- var finish;
70
-
71
- var backup=function (dbc, upd, fin) {
72
- var module = {};
73
-
74
- if (upd == undefined || dbc == undefined) {
75
- fin("No DB Connection");
76
- return
77
- }
78
- db = dbc;
79
- update = upd;
80
- finish = fin;
81
- module.dump = dump
82
- return module;
83
- };
84
- module.exports = backup
85
-
86
- var DBURL = process.argv[2]
87
- var OVERRIDE_FILE = process.argv[3]
88
- if (DBURL) {
89
-
90
- const mongoose = require('mongoose');
91
- mongoose.Promise = global.Promise;
92
- mongoose.connect(DBURL, {
93
- useUnifiedTopology: true,
94
- useNewUrlParser: true,
95
- }).then(() => {
96
- console.log("Successfully connected to the database");
97
- backup(mongoose.connection.db,()=>{},(msg,blob)=>{
98
- console.log("Backup Complete : Size "+blob.length,' Bytes')
99
- process.exit();
100
- }).dump()
101
- }) .catch(err => {
102
- console.log('Could not connect to the database. Exiting now...', err);
103
- process.exit();
104
- });
105
-
106
-
107
-
1
+ var fs = require('fs');
2
+ const { stringify } = require('querystring');
3
+ async function log(arg) {
4
+ update(arg)
5
+ }
6
+ var maxC = 0;
7
+ var curC = 1;
8
+ async function processCollection(n) {
9
+
10
+ var coll = db.collection(n.name)
11
+ var count = await coll.countDocuments()
12
+ log(n.name + " = " + count);
13
+ await coll.find()
14
+ .toArray((err, results) => {
15
+ if (err) throw err;
16
+
17
+ output[n.name] = results;
18
+ log("Dumped " + n.name + " (" + curC + "/" + maxC + ")");
19
+ if (maxC > curC) {
20
+ curC++;
21
+ }
22
+ else {
23
+ log("\n\n All Dumps completed !!");
24
+ log("Saving to file.... ", file)
25
+ write();
26
+ }
27
+ })
28
+ };
29
+
30
+ async function write(skipWriteToFile) {
31
+ var blob=JSON.stringify(output);
32
+ if (skipWriteToFile !== true) {
33
+
34
+ if(!fs.existsSync('./dumps'))
35
+ fs.mkdirSync('./dumps')
36
+ fs.writeFileSync(file, blob);
37
+
38
+ }
39
+ finish("Done !", blob);
40
+ }
41
+
42
+ function getDateString() {
43
+ var d = new Date();
44
+
45
+ var datestring = d.getFullYear() + "" + (d.getMonth() + 1) + "" + d.getDate() + "_" +
46
+ d.getHours() + "" + d.getMinutes();
47
+
48
+ return datestring;
49
+ }
50
+
51
+ var output = {};
52
+ var file;
53
+ var db;
54
+ async function dump() {
55
+ file = "dumps/dump_" + getDateString() + ".json";
56
+ if(OVERRIDE_FILE){
57
+ file=OVERRIDE_FILE;
58
+ }
59
+ log("Dumps Saved to " + file);
60
+ db.listCollections().toArray(function (err, names) {
61
+
62
+ maxC = names.length;
63
+ names.forEach(processCollection)
64
+ });
65
+
66
+ }
67
+
68
+ var update;
69
+ var finish;
70
+
71
+ var backup=function (dbc, upd, fin) {
72
+ var module = {};
73
+
74
+ if (upd == undefined || dbc == undefined) {
75
+ fin("No DB Connection");
76
+ return
77
+ }
78
+ db = dbc;
79
+ update = upd;
80
+ finish = fin;
81
+ module.dump = dump
82
+ return module;
83
+ };
84
+ module.exports = backup
85
+
86
+ var DBURL = process.argv[2]
87
+ var OVERRIDE_FILE = process.argv[3]
88
+ if (DBURL) {
89
+
90
+ const mongoose = require('mongoose');
91
+ mongoose.Promise = global.Promise;
92
+ mongoose.connect(DBURL, {
93
+ useUnifiedTopology: true,
94
+ useNewUrlParser: true,
95
+ }).then(() => {
96
+ console.log("Successfully connected to the database");
97
+ backup(mongoose.connection.db,()=>{},(msg,blob)=>{
98
+ console.log("Backup Complete : Size "+blob.length,' Bytes')
99
+ process.exit();
100
+ }).dump()
101
+ }) .catch(err => {
102
+ console.log('Could not connect to the database. Exiting now...', err);
103
+ process.exit();
104
+ });
105
+
106
+
107
+
108
108
  }
package/databases.js CHANGED
@@ -1,15 +1,15 @@
1
- const { MultiDbORM } = require("./engines/multidb");
2
- const { FireStoreDB } = require("./engines/firestoredb");
3
- const { MongoDB } = require("./engines/mongodb");
4
- const { SQLiteDB } = require("./engines/sqlitedb");
5
- const { OracleDB } = require('./engines/oracledb')
6
- const { MySQLDB } = require('./engines/mysqldb')
7
-
8
- module.exports = {
9
- MultiDbORM,
10
- FireStoreDB,
11
- MongoDB,
12
- SQLiteDB,
13
- OracleDB,
14
- MySQLDB
1
+ const { MultiDbORM } = require("./engines/multidb");
2
+ const { FireStoreDB } = require("./engines/firestoredb");
3
+ const { MongoDB } = require("./engines/mongodb");
4
+ const { SQLiteDB } = require("./engines/sqlitedb");
5
+ const { OracleDB } = require('./engines/oracledb')
6
+ const { MySQLDB } = require('./engines/mysqldb')
7
+
8
+ module.exports = {
9
+ MultiDbORM,
10
+ FireStoreDB,
11
+ MongoDB,
12
+ SQLiteDB,
13
+ OracleDB,
14
+ MySQLDB
15
15
  }
@@ -1,39 +1,39 @@
1
- import { MultiDbORM, MultiDbORMOptions } from './MultiDbORM';
2
-
3
- interface ServiceAccount {
4
- type: string;
5
- project_id: string;
6
- private_key_id: string;
7
- private_key: string;
8
- client_email: string;
9
- client_id: string;
10
- auth_uri: string;
11
- token_uri: string;
12
- auth_provider_x509_cert_url: string;
13
- client_x509_cert_url: string;
14
- }
15
-
16
- export declare class FireStoreDB extends MultiDbORM {
17
- admin: any; // Replace 'any' with actual Firebase Admin library types
18
- serviceAccount: ServiceAccount;
19
-
20
- constructor(serviceAccount: ServiceAccount, appname?: string);
21
-
22
- async run(query: string): Promise<any>;
23
-
24
- attachOptions(modelref: any, options: any): any;
25
-
26
- async _get(modelname: string, filter: any, options?: any): Promise<any>;
27
-
28
- async get(modelname: string, filter: any, options?: any): Promise<any>;
29
-
30
- async getOne(modelname: string, filter: any, id?: string, options?: any): Promise<any>;
31
-
32
- async create(modelname: string, sampleObject: any): Promise<any>;
33
-
34
- async insert(modelname: string, object: any, id?: string): Promise<any>;
35
-
36
- async update(modelname: string, filter: any, object: any, id?: string): Promise<any>;
37
-
38
- async delete(modelname: string, filter: any, id?: string): Promise<any>;
39
- }
1
+ import { MultiDbORM, MultiDbORMOptions } from './MultiDbORM';
2
+
3
+ interface ServiceAccount {
4
+ type: string;
5
+ project_id: string;
6
+ private_key_id: string;
7
+ private_key: string;
8
+ client_email: string;
9
+ client_id: string;
10
+ auth_uri: string;
11
+ token_uri: string;
12
+ auth_provider_x509_cert_url: string;
13
+ client_x509_cert_url: string;
14
+ }
15
+
16
+ export declare class FireStoreDB extends MultiDbORM {
17
+ admin: any; // Replace 'any' with actual Firebase Admin library types
18
+ serviceAccount: ServiceAccount;
19
+
20
+ constructor(serviceAccount: ServiceAccount, appname?: string);
21
+
22
+ async run(query: string): Promise<any>;
23
+
24
+ attachOptions(modelref: any, options: any): any;
25
+
26
+ async _get(modelname: string, filter: any, options?: any): Promise<any>;
27
+
28
+ async get(modelname: string, filter: any, options?: any): Promise<any>;
29
+
30
+ async getOne(modelname: string, filter: any, id?: string, options?: any): Promise<any>;
31
+
32
+ async create(modelname: string, sampleObject: any): Promise<any>;
33
+
34
+ async insert(modelname: string, object: any, id?: string): Promise<any>;
35
+
36
+ async update(modelname: string, filter: any, object: any, id?: string): Promise<any>;
37
+
38
+ async delete(modelname: string, filter: any, id?: string): Promise<any>;
39
+ }