picker-db 3.4.0 → 3.6.0
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/CHANGELOG.md +7 -0
- package/constants.js +6 -0
- package/lib/Mongo/index.js +8 -17
- package/lib/Mongo/typedef.js +19 -0
- package/modules/picker/schemas/bookings.js +11 -1
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
package/constants.js
CHANGED
package/lib/Mongo/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require("./typedef");
|
|
2
|
+
|
|
1
3
|
const mongoose = require("mongoose");
|
|
2
4
|
const _ = require("lodash");
|
|
3
5
|
|
|
@@ -9,18 +11,7 @@ const logger = require("../Logger");
|
|
|
9
11
|
class MongoDB {
|
|
10
12
|
/**
|
|
11
13
|
* Sets up the configuration for the mongo connection
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {string} config.dbName
|
|
14
|
-
* @param {boolean} [config.isLoggingEnabled]
|
|
15
|
-
* @param {boolean} [config.isDebugEnabled]
|
|
16
|
-
* @param {object} config.auth
|
|
17
|
-
* @param {string} config.auth.username
|
|
18
|
-
* @param {string} config.auth.password
|
|
19
|
-
* @param {string} [config.auth.host]
|
|
20
|
-
* @param {string} [config.auth.port]
|
|
21
|
-
* @param {string} [config.auth.environment]
|
|
22
|
-
* @param {boolean} [config.useMongoClient]
|
|
23
|
-
* @param {boolean} [config.useUnifiedTopology]
|
|
14
|
+
* @param {MongoConfig} config
|
|
24
15
|
*/
|
|
25
16
|
constructor (config = {}) {
|
|
26
17
|
this.config = _.defaults(
|
|
@@ -45,15 +36,15 @@ class MongoDB {
|
|
|
45
36
|
|
|
46
37
|
/**
|
|
47
38
|
* Returns connection uri based on environment
|
|
48
|
-
* @param {
|
|
49
|
-
* @
|
|
50
|
-
* @param {string} auth.password
|
|
51
|
-
* @param {string} [auth.host]
|
|
52
|
-
* @param {string} [auth.port]
|
|
39
|
+
* @param {MongoAuth} auth
|
|
40
|
+
* @returns {string}
|
|
53
41
|
*/
|
|
54
42
|
getUri (auth) {
|
|
55
43
|
let uri = "";
|
|
56
44
|
switch (auth.environment) {
|
|
45
|
+
case "atlas":
|
|
46
|
+
uri = auth.dbUri;
|
|
47
|
+
break;
|
|
57
48
|
case "local":
|
|
58
49
|
uri = `mongodb://${auth.host}:${auth.port}/${this.config.dbName}`;
|
|
59
50
|
break;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef MongoConfig
|
|
3
|
+
* @property {string} dbName
|
|
4
|
+
* @property {boolean} [isLoggingEnabled]
|
|
5
|
+
* @property {boolean} [isDebugEnabled]
|
|
6
|
+
* @property {boolean} [useMongoClient]
|
|
7
|
+
* @property {boolean} [useUnifiedTopology]
|
|
8
|
+
* @property {MongoAuth} auth
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef MongoAuth
|
|
13
|
+
* @property {string} [environment]
|
|
14
|
+
* @property {string} [username]
|
|
15
|
+
* @property {string} [password]
|
|
16
|
+
* @property {string} [host]
|
|
17
|
+
* @property {string} [port]
|
|
18
|
+
* @property {string} [dbUri]
|
|
19
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { VEHICLE_TYPES, PAYMENT_METHODS, BOOKING_TYPES, BOOKING_STATUS } = require("../../../constants");
|
|
1
|
+
const { VEHICLE_TYPES, PAYMENT_METHODS, BOOKING_TYPES, BOOKING_STATUS, DELIVERY_CHARGE_TYPE } = require("../../../constants");
|
|
2
2
|
const { DEVICE_TYPES } = require("../../../constants").USER;
|
|
3
3
|
|
|
4
4
|
const PricingDetailsSchema = require("./pricingDetails");
|
|
@@ -676,6 +676,16 @@ module.exports = (connection) => {
|
|
|
676
676
|
type: Boolean,
|
|
677
677
|
default: true,
|
|
678
678
|
},
|
|
679
|
+
typeDeliveryCharge: {
|
|
680
|
+
type: String,
|
|
681
|
+
enum: [
|
|
682
|
+
DELIVERY_CHARGE_TYPE.NO_CHARGE,
|
|
683
|
+
DELIVERY_CHARGE_TYPE.CUSTOM_VALUE,
|
|
684
|
+
DELIVERY_CHARGE_TYPE.RECOMMENDED_VALUE,
|
|
685
|
+
DELIVERY_CHARGE_TYPE.NONE,
|
|
686
|
+
],
|
|
687
|
+
default: DELIVERY_CHARGE_TYPE.NONE,
|
|
688
|
+
},
|
|
679
689
|
}, { timestamps: true });
|
|
680
690
|
|
|
681
691
|
BookingSchema.pre("save", function (next) {
|