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) {
|
||||
var self = this;
|
||||
|
||||
this.db.collection(collections.ADDRESSES).find({
|
||||
function getResult(cb) {
|
||||
self.db.collection(collections.ADDRESSES).find({
|
||||
walletId: walletId,
|
||||
$or: [{
|
||||
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: {
|
||||
$exists: false
|
||||
},
|
||||
}]
|
||||
}).toArray(function(err, result) {
|
||||
}).toArray(cb);
|
||||
});
|
||||
};
|
||||
|
||||
getResult(function(err, result) {
|
||||
if (err) return cb(err);
|
||||
if (!result) return cb();
|
||||
|
||||
var addresses = _.map(result, function(address) {
|
||||
return Model.Address.fromObj(address);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue