@positivegrid/pg-mongoose-schema 26.6.0 → 26.7.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.
- package/models/partner.js +13 -0
- package/models/user.js +2 -1
- package/package.json +1 -1
package/models/partner.js
CHANGED
|
@@ -16,6 +16,8 @@ module.exports = function (mongoose) {
|
|
|
16
16
|
status: { type: Number, default: 1, required: true }, // 1: active, 2: inactive
|
|
17
17
|
created_on: { type: Date, default: Date.now }
|
|
18
18
|
}, { collection: 'pg_partner_sales_meta' })
|
|
19
|
+
PartnerSalesMetaSchema.index({ partner_name: 1, status: 1 })
|
|
20
|
+
PartnerSalesMetaSchema.index({ sales_product: 1, sales_bundle: 1, status: 1 })
|
|
19
21
|
|
|
20
22
|
const PURCHASE_ITEM_TYPE = ['license', 'bundle']
|
|
21
23
|
const PartnerRedeemSchema = new Schema({
|
|
@@ -31,6 +33,16 @@ module.exports = function (mongoose) {
|
|
|
31
33
|
updated_on: { type: Date, default: Date.now }
|
|
32
34
|
}, { collection: 'pg_partner_redeem' })
|
|
33
35
|
|
|
36
|
+
const PartnerSalesHistorySchema = new Schema({
|
|
37
|
+
partner_name: { type: String, required: true },
|
|
38
|
+
sku: { type: String, required: true },
|
|
39
|
+
title: { type: String, required: true },
|
|
40
|
+
previous_price: { type: Number, required: true },
|
|
41
|
+
current_price: { type: Number, required: true },
|
|
42
|
+
updated_on: { type: Date, default: Date.now }
|
|
43
|
+
}, { collection: 'pg_partner_sales_history' })
|
|
44
|
+
PartnerSalesHistorySchema.index({ partner_name: 1, sku: 1 })
|
|
45
|
+
|
|
34
46
|
/**
|
|
35
47
|
* B2bRedeemSchema is the db table for B2B redeem purchase records.
|
|
36
48
|
* Our dealer will purchase the redeem code they need and all detail will save in pg_b2b_redeem_order and pg_b2b_redeem
|
|
@@ -245,6 +257,7 @@ module.exports = function (mongoose) {
|
|
|
245
257
|
|
|
246
258
|
mongoose.model('PartnerSalesMeta', PartnerSalesMetaSchema)
|
|
247
259
|
mongoose.model('PartnerRedeem', PartnerRedeemSchema)
|
|
260
|
+
mongoose.model('PartnerSalesHistory', PartnerSalesHistorySchema)
|
|
248
261
|
mongoose.model('B2bRedeemOrder', B2bRedeemOrderSchema)
|
|
249
262
|
mongoose.model('B2bRedeem', B2bRedeemSchema)
|
|
250
263
|
mongoose.model('B2bDealer', B2bDealerSchema)
|
package/models/user.js
CHANGED
|
@@ -96,6 +96,7 @@ module.exports = function (mongoose) {
|
|
|
96
96
|
fb_access_token: { type: String, default: null },
|
|
97
97
|
facebook_id: { type: String, default: null },
|
|
98
98
|
shopify_id: { type: Schema.Types.Mixed, default: null },
|
|
99
|
+
bk_username: [{ type: String }],
|
|
99
100
|
auth: {
|
|
100
101
|
firebase_id: { type: String },
|
|
101
102
|
google_id: { type: String },
|
|
@@ -275,7 +276,7 @@ module.exports = function (mongoose) {
|
|
|
275
276
|
}
|
|
276
277
|
if (!bgUser) {
|
|
277
278
|
throw new ApiErrorCode('USER_NOT_EXIST', `Cannot find user ${username}`)
|
|
278
|
-
} else if (!
|
|
279
|
+
} else if (!bgUser.authenticate(password)) {
|
|
279
280
|
throw new ApiErrorCode('USER_UNAUTHORIZED', 'unauthorized')
|
|
280
281
|
}
|
|
281
282
|
return bgUser
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positivegrid/pg-mongoose-schema",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.7.1",
|
|
4
4
|
"description": "Positive Grid mongoose schema",
|
|
5
5
|
"author": "Ferrari Lee <shiyung@positivegrid.com>",
|
|
6
6
|
"homepage": "https://git.positivegrid.com:8443/backend/pg-mongoose-schema",
|