picker-db 5.0.2 → 5.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/constants.js CHANGED
@@ -456,5 +456,11 @@ module.exports = {
456
456
  DRIVERS_BUSY: "DRIVERS_BUSY",
457
457
  INVALID_DATA: "INVALID_DATA",
458
458
  PROVIDER_ERROR: "PROVIDER_ERROR"
459
+ },
460
+ BOOKING: {
461
+ BOOKING_STOP_TYPES: {
462
+ PICKUP: "PICKUP",
463
+ DELIVERY: "DELIVERY",
464
+ },
459
465
  }
460
466
  };
@@ -45,6 +45,25 @@ class PickerMongoDBService {
45
45
  });
46
46
  }
47
47
 
48
+ /**
49
+ * Wrapper around 'insertMany' method
50
+ * @description Inserts multiple documents in the database
51
+ * @param {string} modelName Name of the model for this operation
52
+ * @param {object[]} arrObjToSave Array of documents to save
53
+ * @returns {Promise<object[]>}
54
+ */
55
+ async createMany (modelName, arrObjToSave) {
56
+ return new Promise((resolve, reject) => {
57
+ this.models[modelName].insertMany(arrObjToSave)
58
+ .then((res) => {
59
+ return resolve(res);
60
+ })
61
+ .catch((err) => {
62
+ return reject(err);
63
+ });
64
+ });
65
+ }
66
+
48
67
  /**
49
68
  * Wrapper around 'find' method
50
69
  * @description Returns all documents that match the query
@@ -26,6 +26,8 @@ const MiniBookingSchema = require("../schemas/miniBooking");
26
26
  const BookingDriverDetailsSchema = require("../schemas/bookingDriverDetails");
27
27
  const ConversationSchema = require("../schemas/conversation");
28
28
  const BookingMetadataSchema = require("../schemas/bookingMetadata");
29
+ const BookingStopSchema = require("../schemas/bookingStop");
30
+ const UserAuditLogSchema = require("../schemas/userAuditLog");
29
31
 
30
32
  /** @param {import("mongoose")} connection */
31
33
  module.exports = (connection) => {
@@ -58,5 +60,7 @@ module.exports = (connection) => {
58
60
  BookingDriverDetails: connection.model("BookingDriverDetails", BookingDriverDetailsSchema(connection)),
59
61
  Conversation: connection.model("Conversation", ConversationSchema(connection)),
60
62
  BookingMetadata: connection.model("BookingMetadata", BookingMetadataSchema(connection)),
63
+ BookingStop: connection.model("BookingStop", BookingStopSchema(connection)),
64
+ UserAuditLog: connection.model("UserAuditLog", UserAuditLogSchema(connection)),
61
65
  };
62
66
  };
@@ -0,0 +1,49 @@
1
+ const { BOOKING } = require("../../../constants");
2
+
3
+ module.exports = (connection) => {
4
+ const BookingStopSchema = new connection.base.Schema({
5
+ bookingID: {
6
+ type: connection.base.Schema.ObjectId,
7
+ ref: "Bookings",
8
+ index: true,
9
+ required: true,
10
+ },
11
+ type: {
12
+ type: String,
13
+ enum: [BOOKING.BOOKING_STOP_TYPES.PICKUP, BOOKING.BOOKING_STOP_TYPES.DELIVERY],
14
+ required: true,
15
+ },
16
+ business: {
17
+ type: connection.base.Schema.ObjectId,
18
+ ref: "User",
19
+ required: true,
20
+ },
21
+ address: {
22
+ type: String,
23
+ },
24
+ coordinates: {
25
+ type: {
26
+ type: String,
27
+ enum: ["Point"],
28
+ },
29
+ coordinates: {
30
+ type: [Number],
31
+ },
32
+ },
33
+ city: {
34
+ type: String,
35
+ },
36
+ zipCode: {
37
+ type: String,
38
+ },
39
+ references: {
40
+ type: String,
41
+ },
42
+ orderIndex: {
43
+ type: Number,
44
+ required: true,
45
+ },
46
+ }, { timestamps: true, strict: false });
47
+
48
+ return BookingStopSchema;
49
+ };
@@ -0,0 +1,24 @@
1
+ /** @param {import("mongoose")} connection */
2
+ module.exports = (connection) => {
3
+ const UserAuditLogSchema = new connection.base.Schema({
4
+ event: {
5
+ type: String,
6
+ required: true,
7
+ index: true,
8
+ },
9
+ userId: {
10
+ type: connection.base.Schema.ObjectId,
11
+ ref: "User",
12
+ required: true,
13
+ index: true,
14
+ },
15
+ performedBy: {
16
+ type: connection.base.Schema.ObjectId,
17
+ ref: "User",
18
+ },
19
+ ip: { type: String },
20
+ metadata: { type: JSON },
21
+ }, { timestamps: true });
22
+
23
+ return UserAuditLogSchema;
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picker-db",
3
- "version": "5.0.2",
3
+ "version": "5.0.6",
4
4
  "description": "Picker DB services",
5
5
  "main": "index.js",
6
6
  "scripts": {