picker-db 4.2.4 → 4.3.1
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.
|
@@ -892,21 +892,25 @@ module.exports = (connection) => {
|
|
|
892
892
|
},
|
|
893
893
|
}, { timestamps: true });
|
|
894
894
|
|
|
895
|
-
BookingSchema.pre("save", function (next) {
|
|
895
|
+
BookingSchema.pre("save", async function (next) {
|
|
896
896
|
if (!this.isNew) {
|
|
897
897
|
return next();
|
|
898
898
|
}
|
|
899
899
|
const doc = this;
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
900
|
+
|
|
901
|
+
if (!doc.bookingNumericId) {
|
|
902
|
+
try {
|
|
903
|
+
const query = { model: "Bookings" };
|
|
904
|
+
const update = { $inc: { count: 1 } };
|
|
905
|
+
const options = { new: true };
|
|
906
|
+
const result = await IdentityCounterModel.findOneAndUpdate(query, update, options);
|
|
907
|
+
doc.bookingNumericId = result.count;
|
|
908
|
+
return next();
|
|
909
|
+
} catch (error) {
|
|
905
910
|
return next(error);
|
|
906
911
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
});
|
|
912
|
+
}
|
|
913
|
+
return next();
|
|
910
914
|
});
|
|
911
915
|
|
|
912
916
|
return BookingSchema;
|
|
@@ -6,19 +6,19 @@ module.exports = (connection) => {
|
|
|
6
6
|
min: {
|
|
7
7
|
type: Number,
|
|
8
8
|
min: 0,
|
|
9
|
-
max:
|
|
9
|
+
max: 9999,
|
|
10
10
|
default: 0,
|
|
11
11
|
},
|
|
12
12
|
max: {
|
|
13
13
|
type: Number,
|
|
14
14
|
min: 0,
|
|
15
|
-
max:
|
|
15
|
+
max: 9999,
|
|
16
16
|
default: 100,
|
|
17
17
|
},
|
|
18
18
|
amount: {
|
|
19
19
|
type: Number,
|
|
20
20
|
min: 0,
|
|
21
|
-
max:
|
|
21
|
+
max: 999999,
|
|
22
22
|
default: 0,
|
|
23
23
|
},
|
|
24
24
|
}, { _id: false });
|