Skip to content

Commit

Permalink
Delete if you don't need it
Browse files Browse the repository at this point in the history
  • Loading branch information
micahriggan committed Jan 26, 2019
1 parent 0dd7303 commit 8f67c03
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/bitcore-node/src/models/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ export class TransactionModel extends BaseModel<ITransaction> {
.map(wallet => wallet.wallet);
mintOp.updateOne.update.$set.wallets = transformedWallets;
delete mintOp.updateOne.update.$setOnInsert.wallets;
if (!Object.keys(mintOp.updateOne.update.$setOnInsert).length) {
delete mintOp.updateOne.update.$setOnInsert;
}
return mintOp;
});
}
Expand Down Expand Up @@ -436,6 +439,9 @@ export class TransactionModel extends BaseModel<ITransaction> {
if (sameBlockSpend) {
sameBlockSpend.updateOne.update.$set.spentHeight = height;
delete sameBlockSpend.updateOne.update.$setOnInsert.spentHeight;
if (!Object.keys(sameBlockSpend.updateOne.update.$setOnInsert).length) {
delete sameBlockSpend.updateOne.update.$setOnInsert;
}
sameBlockSpend.updateOne.update.$set.spentTxid = tx._hash;
continue;
}
Expand Down

0 comments on commit 8f67c03

Please sign in to comment.