@riocrypto/common-server 1.0.2816 → 1.0.2819

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.
@@ -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;
@@ -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,10 @@ 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
+ orderSchema.pre("validate", function (next) {
390
+ this.rootUserId = this.brokerId || this.userId;
391
+ next();
392
+ });
386
393
  orderSchema.statics.build = (attrs) => {
387
394
  return new Order(attrs);
388
395
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2816",
3
+ "version": "1.0.2819",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",