0
.map()を使用した後に得られる新しい値で結果をソートしたい。これはどのように管理しやすいのですか?私は運が無ければAPIに相談しました。値をマッピングした後のコレクションの整列/ソート
私の例では、異なる通貨の価格がデータベースに格納されていますが、日々の為替レートを適用した後に価格で注文したいと考えています。事前に
r.table('price_variants')
.orderBy({index: 'price'})
.filter({'productID': product('id'), 'currentlyUsed': true})
.limit(1)
.map(function(variant) {
variant = variant.merge({
price: r.branch(
variant
.hasFields('exchange_type')
.and(variant('exchange_type')
.eq('EURUSD')), //IF EUR
variant('price').mul(exchangeRateUSDEUR), //THEN convert to USD
variant('price')), //ELSE just use original price
)
})
})
ありがとう:
は、ここに私のReQLクエリです!