call toObject before storing models
This commit is contained in:
parent
80d1d31130
commit
1b6980fd1e
|
@ -145,6 +145,12 @@ TxProposal.fromObj = function(obj) {
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TxProposal.prototype.toObject = function() {
|
||||||
|
var x = _.cloneDeep(this);
|
||||||
|
x.isPending = this.isPending();
|
||||||
|
return x;
|
||||||
|
};
|
||||||
|
|
||||||
TxProposal.prototype.setInputs = function(inputs) {
|
TxProposal.prototype.setInputs = function(inputs) {
|
||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
this.inputPaths = _.pluck(inputs, 'path');
|
this.inputPaths = _.pluck(inputs, 'path');
|
||||||
|
|
|
@ -65,6 +65,12 @@ Wallet.fromObj = function(obj) {
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Wallet.prototype.toObject = function() {
|
||||||
|
var x = _.cloneDeep(this);
|
||||||
|
x.isShared = this.isShared();
|
||||||
|
return x;
|
||||||
|
};
|
||||||
|
|
||||||
/* For compressed keys, m*73 + n*34 <= 496 */
|
/* For compressed keys, m*73 + n*34 <= 496 */
|
||||||
Wallet.COPAYER_PAIR_LIMITS = {
|
Wallet.COPAYER_PAIR_LIMITS = {
|
||||||
1: 1,
|
1: 1,
|
||||||
|
|
|
@ -101,7 +101,7 @@ Storage.prototype.fetchWallet = function(id, cb) {
|
||||||
Storage.prototype.storeWallet = function(wallet, cb) {
|
Storage.prototype.storeWallet = function(wallet, cb) {
|
||||||
this.db.collection(collections.WALLETS).update({
|
this.db.collection(collections.WALLETS).update({
|
||||||
id: wallet.id
|
id: wallet.id
|
||||||
}, wallet, {
|
}, wallet.toObject(), {
|
||||||
w: 1,
|
w: 1,
|
||||||
upsert: true,
|
upsert: true,
|
||||||
}, cb);
|
}, cb);
|
||||||
|
@ -326,11 +326,10 @@ Storage.prototype.storeNotification = function(walletId, notification, cb) {
|
||||||
|
|
||||||
// TODO: remove walletId from signature
|
// TODO: remove walletId from signature
|
||||||
Storage.prototype.storeTx = function(walletId, txp, cb) {
|
Storage.prototype.storeTx = function(walletId, txp, cb) {
|
||||||
txp.isPending = txp.isPending(); // Persist attribute to use when querying
|
|
||||||
this.db.collection(collections.TXS).update({
|
this.db.collection(collections.TXS).update({
|
||||||
id: txp.id,
|
id: txp.id,
|
||||||
walletId: walletId
|
walletId: walletId
|
||||||
}, txp, {
|
}, txp.toObject(), {
|
||||||
w: 1,
|
w: 1,
|
||||||
upsert: true,
|
upsert: true,
|
||||||
}, cb);
|
}, cb);
|
||||||
|
|
Loading…
Reference in New Issue