fix query condition for tingodb
This commit is contained in:
parent
f69d5a5bb4
commit
bb489df824
|
@ -931,18 +931,26 @@ Storage.prototype.updateHasBalance = function(addresses, hasBalance, cb) {
|
||||||
Storage.prototype.fetchAddressesWithBalance = function(walletId, cb) {
|
Storage.prototype.fetchAddressesWithBalance = function(walletId, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.db.collection(collections.ADDRESSES).find({
|
function getResult(cb) {
|
||||||
|
self.db.collection(collections.ADDRESSES).find({
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
$or: [{
|
|
||||||
hasBalance: true,
|
hasBalance: true,
|
||||||
}, {
|
}).toArray(function(err, result) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
if (!_.isEmpty(result)) return cb(null, result);
|
||||||
|
self.db.collection(collections.ADDRESSES).find({
|
||||||
|
walletId: walletId,
|
||||||
hasBalance: {
|
hasBalance: {
|
||||||
$exists: false
|
$exists: false
|
||||||
},
|
},
|
||||||
}]
|
}).toArray(cb);
|
||||||
}).toArray(function(err, result) {
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getResult(function(err, result) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (!result) return cb();
|
if (!result) return cb();
|
||||||
|
|
||||||
var addresses = _.map(result, function(address) {
|
var addresses = _.map(result, function(address) {
|
||||||
return Model.Address.fromObj(address);
|
return Model.Address.fromObj(address);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue