picker-db 3.4.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/.editorconfig +8 -0
- package/.eslintignore +9 -0
- package/.eslintrc.json +35 -0
- package/.nvmrc +1 -0
- package/.vscode/settings.json +11 -0
- package/README.md +21 -0
- package/bitbucket-pipelines.yml +24 -0
- package/constants.js +420 -0
- package/index.js +5 -0
- package/lib/Logger/index.js +45 -0
- package/lib/Mongo/index.js +126 -0
- package/modules/picker/index.js +259 -0
- package/modules/picker/models/identityCounter.js +15 -0
- package/modules/picker/models/index.js +50 -0
- package/modules/picker/schemas/address.js +74 -0
- package/modules/picker/schemas/adminSetting.js +125 -0
- package/modules/picker/schemas/balanceTransaction.js +132 -0
- package/modules/picker/schemas/bill.js +70 -0
- package/modules/picker/schemas/bookingProduct.js +50 -0
- package/modules/picker/schemas/bookings.js +699 -0
- package/modules/picker/schemas/business.js +231 -0
- package/modules/picker/schemas/businessCategory.js +61 -0
- package/modules/picker/schemas/customer.js +28 -0
- package/modules/picker/schemas/driver.js +162 -0
- package/modules/picker/schemas/fareSettings.js +122 -0
- package/modules/picker/schemas/fraudBooking.js +21 -0
- package/modules/picker/schemas/identityCounter.js +10 -0
- package/modules/picker/schemas/kmRange.js +27 -0
- package/modules/picker/schemas/massDelivery.js +119 -0
- package/modules/picker/schemas/notification.js +76 -0
- package/modules/picker/schemas/paymentezCustomer.js +41 -0
- package/modules/picker/schemas/paymentezTransaction.js +67 -0
- package/modules/picker/schemas/preference.js +40 -0
- package/modules/picker/schemas/pricingDetails.js +90 -0
- package/modules/picker/schemas/referralUsage.js +33 -0
- package/modules/picker/schemas/region.js +75 -0
- package/modules/picker/schemas/review.js +42 -0
- package/modules/picker/schemas/session.js +25 -0
- package/modules/picker/schemas/superRegion.js +41 -0
- package/modules/picker/schemas/user.js +337 -0
- package/package.json +29 -0
- package/playground/testConnection.js +24 -0
- package/playground/testService.js +27 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
const { SOCIAL_ACCOUNTS, API_USER } = require("../../../constants");
|
|
2
|
+
|
|
3
|
+
/** @param {import("mongoose")} connection */
|
|
4
|
+
module.exports = (connection) => {
|
|
5
|
+
const ExternalAPIConfSchema = new connection.base.Schema({
|
|
6
|
+
apiKey: {
|
|
7
|
+
type: String,
|
|
8
|
+
index: true,
|
|
9
|
+
},
|
|
10
|
+
masterKey: String, // For Spoonity systems
|
|
11
|
+
payment: {
|
|
12
|
+
maxTries: {
|
|
13
|
+
type: Number,
|
|
14
|
+
default: 3,
|
|
15
|
+
min: 0,
|
|
16
|
+
},
|
|
17
|
+
actualTries: {
|
|
18
|
+
type: Number,
|
|
19
|
+
default: 0,
|
|
20
|
+
min: 0,
|
|
21
|
+
},
|
|
22
|
+
paymentMethod: String,
|
|
23
|
+
},
|
|
24
|
+
billing: {
|
|
25
|
+
method: {
|
|
26
|
+
type: String,
|
|
27
|
+
enum: [
|
|
28
|
+
API_USER.BILLING_METHOD.CARD,
|
|
29
|
+
API_USER.BILLING_METHOD.TRANSFER,
|
|
30
|
+
],
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
maxDeliveryDistance: {
|
|
35
|
+
type: Number,
|
|
36
|
+
min: 0,
|
|
37
|
+
}, // In kms
|
|
38
|
+
bookingType: { type: String },
|
|
39
|
+
deliveryFee: { type: Number },
|
|
40
|
+
}, { _id: false });
|
|
41
|
+
|
|
42
|
+
const ContactSchema = new connection.base.Schema({
|
|
43
|
+
mobile: { type: String },
|
|
44
|
+
isVerified: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
isPrimary: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false,
|
|
51
|
+
},
|
|
52
|
+
mobileOTP: { type: Number },
|
|
53
|
+
countryCode: { type: String },
|
|
54
|
+
otpUpdatedAt: { type: Date },
|
|
55
|
+
role: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: "",
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const UserSchema = new connection.base.Schema({
|
|
62
|
+
userUniqueID: { type: String },
|
|
63
|
+
contacts: [ContactSchema],
|
|
64
|
+
name: {
|
|
65
|
+
type: String,
|
|
66
|
+
trim: true,
|
|
67
|
+
index: true,
|
|
68
|
+
default: null,
|
|
69
|
+
sparse: true,
|
|
70
|
+
},
|
|
71
|
+
lastName: {
|
|
72
|
+
type: String,
|
|
73
|
+
trim: true,
|
|
74
|
+
default: "",
|
|
75
|
+
},
|
|
76
|
+
email: {
|
|
77
|
+
type: String,
|
|
78
|
+
trim: true,
|
|
79
|
+
index: true,
|
|
80
|
+
sparse: true,
|
|
81
|
+
},
|
|
82
|
+
countryCode: { type: String },
|
|
83
|
+
mobile: {
|
|
84
|
+
type: String,
|
|
85
|
+
index: true,
|
|
86
|
+
trim: true,
|
|
87
|
+
sparse: true,
|
|
88
|
+
},
|
|
89
|
+
fullMobile: {
|
|
90
|
+
type: String,
|
|
91
|
+
index: true,
|
|
92
|
+
},
|
|
93
|
+
password: {
|
|
94
|
+
type: String,
|
|
95
|
+
required: false,
|
|
96
|
+
},
|
|
97
|
+
dateOfBirth: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: "",
|
|
100
|
+
},
|
|
101
|
+
identityNumber: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: "",
|
|
104
|
+
},
|
|
105
|
+
forgotPasswordMobileOTP: {
|
|
106
|
+
type: Number,
|
|
107
|
+
index: true,
|
|
108
|
+
time: true,
|
|
109
|
+
sparse: true,
|
|
110
|
+
},
|
|
111
|
+
emailVerificationToken: {
|
|
112
|
+
type: String,
|
|
113
|
+
required: false,
|
|
114
|
+
},
|
|
115
|
+
emailVerificationTokenUpdatedAt: { type: Date },
|
|
116
|
+
otpResendTimes: {
|
|
117
|
+
type: Number,
|
|
118
|
+
max: 3,
|
|
119
|
+
},
|
|
120
|
+
utcoffset: { type: Number },
|
|
121
|
+
language: {
|
|
122
|
+
type: String,
|
|
123
|
+
},
|
|
124
|
+
passwordResetToken: {
|
|
125
|
+
type: String,
|
|
126
|
+
default: null,
|
|
127
|
+
},
|
|
128
|
+
totalRatingPoints: {
|
|
129
|
+
type: Number,
|
|
130
|
+
default: 0,
|
|
131
|
+
},
|
|
132
|
+
ratedByUserCount: {
|
|
133
|
+
type: Number,
|
|
134
|
+
default: 0,
|
|
135
|
+
},
|
|
136
|
+
createdBy: {
|
|
137
|
+
type: connection.base.Schema.ObjectId,
|
|
138
|
+
ref: "User",
|
|
139
|
+
default: null,
|
|
140
|
+
},
|
|
141
|
+
assignedBy: {
|
|
142
|
+
type: connection.base.Schema.ObjectId,
|
|
143
|
+
ref: "User",
|
|
144
|
+
default: null,
|
|
145
|
+
},
|
|
146
|
+
assignedTo: {
|
|
147
|
+
type: connection.base.Schema.ObjectId,
|
|
148
|
+
ref: "User",
|
|
149
|
+
default: null,
|
|
150
|
+
},
|
|
151
|
+
totalCreatedUsers: {
|
|
152
|
+
type: Number,
|
|
153
|
+
default: 0,
|
|
154
|
+
},
|
|
155
|
+
role: [{
|
|
156
|
+
type: String,
|
|
157
|
+
}],
|
|
158
|
+
customerID: {
|
|
159
|
+
type: connection.base.Schema.ObjectId,
|
|
160
|
+
ref: "Customer",
|
|
161
|
+
default: null,
|
|
162
|
+
},
|
|
163
|
+
serviceProviderID: {
|
|
164
|
+
type: connection.base.Schema.ObjectId,
|
|
165
|
+
ref: "ServiceProvider",
|
|
166
|
+
default: null,
|
|
167
|
+
},
|
|
168
|
+
driverID: {
|
|
169
|
+
type: connection.base.Schema.ObjectId,
|
|
170
|
+
ref: "Driver",
|
|
171
|
+
default: null,
|
|
172
|
+
},
|
|
173
|
+
businessID: {
|
|
174
|
+
type: connection.base.Schema.ObjectId,
|
|
175
|
+
ref: "Business",
|
|
176
|
+
default: null,
|
|
177
|
+
},
|
|
178
|
+
customerAddressID: {
|
|
179
|
+
type: connection.base.Schema.ObjectId,
|
|
180
|
+
ref: "Address",
|
|
181
|
+
default: null,
|
|
182
|
+
},
|
|
183
|
+
serviceProviderAddressID: {
|
|
184
|
+
type: connection.base.Schema.ObjectId,
|
|
185
|
+
ref: "Address",
|
|
186
|
+
default: null,
|
|
187
|
+
},
|
|
188
|
+
driverAddressID: {
|
|
189
|
+
type: connection.base.Schema.ObjectId,
|
|
190
|
+
ref: "Address",
|
|
191
|
+
default: null,
|
|
192
|
+
},
|
|
193
|
+
businessAddressID: {
|
|
194
|
+
type: connection.base.Schema.ObjectId,
|
|
195
|
+
ref: "Address",
|
|
196
|
+
default: null,
|
|
197
|
+
},
|
|
198
|
+
socialAccounts: [{
|
|
199
|
+
type: {
|
|
200
|
+
type: String,
|
|
201
|
+
enum: [
|
|
202
|
+
SOCIAL_ACCOUNTS.FACEBOOK,
|
|
203
|
+
SOCIAL_ACCOUNTS.GOOGLE,
|
|
204
|
+
SOCIAL_ACCOUNTS.APPLE,
|
|
205
|
+
],
|
|
206
|
+
},
|
|
207
|
+
socialID: { type: String },
|
|
208
|
+
_id: false,
|
|
209
|
+
}],
|
|
210
|
+
image: {
|
|
211
|
+
thumbnail: { type: String, default: null },
|
|
212
|
+
original: { type: String, default: null },
|
|
213
|
+
},
|
|
214
|
+
isBlocked: {
|
|
215
|
+
type: Boolean,
|
|
216
|
+
default: false,
|
|
217
|
+
required: true,
|
|
218
|
+
},
|
|
219
|
+
isDeleted: {
|
|
220
|
+
type: Boolean,
|
|
221
|
+
default: false,
|
|
222
|
+
required: true,
|
|
223
|
+
},
|
|
224
|
+
isAdminVerified: {
|
|
225
|
+
type: Boolean,
|
|
226
|
+
default: false,
|
|
227
|
+
required: true,
|
|
228
|
+
},
|
|
229
|
+
isEmailVerified: {
|
|
230
|
+
type: Boolean,
|
|
231
|
+
default: false,
|
|
232
|
+
required: true,
|
|
233
|
+
},
|
|
234
|
+
isPhoneVerified: {
|
|
235
|
+
type: Boolean,
|
|
236
|
+
default: false,
|
|
237
|
+
required: true,
|
|
238
|
+
},
|
|
239
|
+
promoAdded: {
|
|
240
|
+
type: connection.base.Schema.ObjectId,
|
|
241
|
+
ref: "Promo",
|
|
242
|
+
default: null,
|
|
243
|
+
},
|
|
244
|
+
onDutyFlag: {
|
|
245
|
+
type: Boolean,
|
|
246
|
+
default: false,
|
|
247
|
+
},
|
|
248
|
+
isBusy: {
|
|
249
|
+
type: Boolean,
|
|
250
|
+
default: false,
|
|
251
|
+
},
|
|
252
|
+
lastOnDutyFlagTime: { type: Date },
|
|
253
|
+
online: {
|
|
254
|
+
type: Boolean,
|
|
255
|
+
default: true,
|
|
256
|
+
},
|
|
257
|
+
firstTimeUser: { type: Boolean },
|
|
258
|
+
deviceToken: {
|
|
259
|
+
type: String,
|
|
260
|
+
trim: true,
|
|
261
|
+
index: true,
|
|
262
|
+
sparse: true,
|
|
263
|
+
},
|
|
264
|
+
deviceID: {
|
|
265
|
+
type: String,
|
|
266
|
+
trim: true,
|
|
267
|
+
index: true,
|
|
268
|
+
sparse: true,
|
|
269
|
+
},
|
|
270
|
+
bankDetails: {
|
|
271
|
+
bankName: { type: String },
|
|
272
|
+
accountNumber: { type: String },
|
|
273
|
+
accountOwnerName: { type: String },
|
|
274
|
+
accountType: { type: String },
|
|
275
|
+
},
|
|
276
|
+
favoriteDrivers: [{
|
|
277
|
+
type: connection.base.Schema.ObjectId,
|
|
278
|
+
ref: "User",
|
|
279
|
+
default: null,
|
|
280
|
+
}],
|
|
281
|
+
favoriteProducts: [{
|
|
282
|
+
type: connection.base.Schema.ObjectId,
|
|
283
|
+
ref: "Product",
|
|
284
|
+
default: null,
|
|
285
|
+
}],
|
|
286
|
+
favoriteBusinesses: [{
|
|
287
|
+
type: connection.base.Schema.ObjectId,
|
|
288
|
+
ref: "Business",
|
|
289
|
+
default: null,
|
|
290
|
+
}],
|
|
291
|
+
status: {
|
|
292
|
+
type: String,
|
|
293
|
+
},
|
|
294
|
+
apiKey: {
|
|
295
|
+
type: String,
|
|
296
|
+
},
|
|
297
|
+
externalAPIConfiguration: ExternalAPIConfSchema,
|
|
298
|
+
firebaseID: {
|
|
299
|
+
type: String,
|
|
300
|
+
},
|
|
301
|
+
addCardToken: {
|
|
302
|
+
type: String,
|
|
303
|
+
index: true,
|
|
304
|
+
sparse: true,
|
|
305
|
+
},
|
|
306
|
+
addCardTokenUpdatedAt: { type: Date },
|
|
307
|
+
businessAccess: {
|
|
308
|
+
type: Array,
|
|
309
|
+
},
|
|
310
|
+
superRegionID: {
|
|
311
|
+
type: connection.base.Schema.ObjectId,
|
|
312
|
+
ref: "SuperRegion",
|
|
313
|
+
default: null,
|
|
314
|
+
index: true,
|
|
315
|
+
sparse: true,
|
|
316
|
+
},
|
|
317
|
+
groups: [
|
|
318
|
+
{
|
|
319
|
+
type: connection.base.Schema.ObjectId,
|
|
320
|
+
ref: "PermissionGroups",
|
|
321
|
+
default: null,
|
|
322
|
+
index: true,
|
|
323
|
+
sparse: true,
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
dashboardInviteToken: {
|
|
327
|
+
type: String,
|
|
328
|
+
index: true,
|
|
329
|
+
sparse: true,
|
|
330
|
+
},
|
|
331
|
+
dashboardInviteTokenDate: {
|
|
332
|
+
type: Date,
|
|
333
|
+
},
|
|
334
|
+
}, { timestamps: true });
|
|
335
|
+
|
|
336
|
+
return UserSchema;
|
|
337
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "picker-db",
|
|
3
|
+
"version": "3.4.0",
|
|
4
|
+
"description": "Picker DB services",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"author": "edison_andre_9@hotmail.com",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"babel-eslint": "^10.1.0",
|
|
13
|
+
"chai": "^4.2.0",
|
|
14
|
+
"eslint": "^7.9.0",
|
|
15
|
+
"eslint-config-standard": "^14.1.1",
|
|
16
|
+
"eslint-plugin-import": "^2.22.0",
|
|
17
|
+
"eslint-plugin-node": "^11.1.0",
|
|
18
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
19
|
+
"eslint-plugin-standard": "^4.0.1",
|
|
20
|
+
"mocha": "^8.1.3",
|
|
21
|
+
"nyc": "^15.1.0",
|
|
22
|
+
"standard": "^14.3.4"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"lodash": "^4.17.20",
|
|
26
|
+
"mongoose": "^6.11.1",
|
|
27
|
+
"winston": "^3.3.3"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const Mongo = require("../lib/Mongo");
|
|
2
|
+
|
|
3
|
+
const main = async () => {
|
|
4
|
+
try {
|
|
5
|
+
const testDB = new Mongo({
|
|
6
|
+
environment: "dev",
|
|
7
|
+
isLoggingEnabled: true,
|
|
8
|
+
dbName: "picker-dev",
|
|
9
|
+
auth: {
|
|
10
|
+
username: "picker",
|
|
11
|
+
password: "ZX5ZJQKo8GN0iMiP",
|
|
12
|
+
host: "34.240.183.91",
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
console.log("db", testDB);
|
|
16
|
+
await testDB.connect();
|
|
17
|
+
const connection = testDB.getConnection();
|
|
18
|
+
console.log("connection", connection);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error("error", error);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
main();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Const PickerDBService = require("../modules/picker");
|
|
2
|
+
const logger = require("../lib/Logger");
|
|
3
|
+
const { PickerMongoDBService } = require("../index");
|
|
4
|
+
|
|
5
|
+
const main = async () => {
|
|
6
|
+
try {
|
|
7
|
+
const Service = new PickerMongoDBService({
|
|
8
|
+
environment: "dev",
|
|
9
|
+
isLoggingEnabled: true,
|
|
10
|
+
isDebugEnabled: false,
|
|
11
|
+
dbName: "picker-dev",
|
|
12
|
+
auth: {
|
|
13
|
+
username: "picker",
|
|
14
|
+
password: "ZX5ZJQKo8GN0iMiP",
|
|
15
|
+
host: "34.240.183.91",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
await Service.connect();
|
|
19
|
+
const res = await Service.getFirstMatch("Bookings", { customerEmail: "edison_andre_9@hotmail.com" }, { customerEmail: 1 }, { lean: true });
|
|
20
|
+
await Service.disconnect();
|
|
21
|
+
logger.debug({ message: res });
|
|
22
|
+
} catch (error) {
|
|
23
|
+
logger.error(error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
main();
|