@riocrypto/common-server 1.0.2816 → 1.0.2818
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/build/models/order.d.ts +2 -0
- package/build/models/order.js +13 -0
- package/package.json +1 -1
package/build/models/order.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ interface OrderAttrs {
|
|
|
35
35
|
withdrawalTxId?: string;
|
|
36
36
|
withdrawalTxIds?: string[];
|
|
37
37
|
brokerId?: string;
|
|
38
|
+
rootUserId?: string;
|
|
38
39
|
limitNetPrice?: number;
|
|
39
40
|
timeInForceStartsAt?: Date;
|
|
40
41
|
timeInForceEndsAt?: Date;
|
|
@@ -181,6 +182,7 @@ interface OrderDoc extends Document {
|
|
|
181
182
|
withdrawalTxId?: string;
|
|
182
183
|
withdrawalTxIds?: string[];
|
|
183
184
|
brokerId?: string;
|
|
185
|
+
rootUserId?: string;
|
|
184
186
|
conversionRateUSD: number;
|
|
185
187
|
conversionRateUSDWithMarkups: number;
|
|
186
188
|
actualConversionRateUSD?: number;
|
package/build/models/order.js
CHANGED
|
@@ -186,6 +186,9 @@ const buildOrder = (mongoose) => {
|
|
|
186
186
|
brokerId: {
|
|
187
187
|
type: String,
|
|
188
188
|
},
|
|
189
|
+
rootUserId: {
|
|
190
|
+
type: String,
|
|
191
|
+
},
|
|
189
192
|
conversionRateUSD: {
|
|
190
193
|
type: Number,
|
|
191
194
|
required: true,
|
|
@@ -383,6 +386,16 @@ const buildOrder = (mongoose) => {
|
|
|
383
386
|
orderSchema.index({ brokerId: 1, "TWAP.sessionId": 1, createdAt: 1 });
|
|
384
387
|
orderSchema.index({ clientReferenceId: 1 }, { sparse: true });
|
|
385
388
|
orderSchema.index({ "paymentsReceived.blockchainTxId": 1 }, { sparse: true });
|
|
389
|
+
// At most one order per real quoteId. Imported orders use quoteId "" and are
|
|
390
|
+
// excluded by the partial filter (which also serves the createOrder lookup).
|
|
391
|
+
orderSchema.index({ quoteId: 1 }, { unique: true, partialFilterExpression: { quoteId: { $gt: "" } } });
|
|
392
|
+
// At most one order per (broker family, clientReferenceId). rootUserId is
|
|
393
|
+
// brokerId || userId; orders without a clientReferenceId are excluded.
|
|
394
|
+
orderSchema.index({ rootUserId: 1, clientReferenceId: 1 }, { unique: true, partialFilterExpression: { clientReferenceId: { $type: "string" } } });
|
|
395
|
+
orderSchema.pre("validate", function (next) {
|
|
396
|
+
this.rootUserId = this.brokerId || this.userId;
|
|
397
|
+
next();
|
|
398
|
+
});
|
|
386
399
|
orderSchema.statics.build = (attrs) => {
|
|
387
400
|
return new Order(attrs);
|
|
388
401
|
};
|