我正在尝试将以下mapObj.addListener('dragend', function () {
var idleListener = mapObj.addListener('idle', function () {
google.maps.event.removeListener(idleListener);
console.log(mapObj.getCenter().lat());
console.log(mapObj.getCenter().lng());
});
});
优化为单个scans
(或scan
)。我看到的唯一方法是使用use a OR
comparator using DynamoDB。我在我的应用程序中使用query
(dynogels
的分叉),但遗憾的是我不知道其中有任何vogels
查询功能。
OR

建议的优化:
let arrivals = yield Reservation.scan()
.where('room').equals(room)
.where('arrival').between(from, to)
.execAsync().then((reply) => reply.Items.map((item) => item.get()));
let departures = yield Reservation.scan()
.where('room').equals(room)
.where('departure').between(from, to)
.execAsync().then((reply) => reply.Items.map((item) => item.get()));
let combined = arrivals.concat(departures);
return Promise.resolve(combined);

扫描系统会在指定的日期范围(return Reservation.scan()
.where('room').equals(room)
.where('arrival').between(from, to)
.or.where('departure').between(from, to)
.execAsync().then((reply) => reply.Items.map((item) => item.get()));
,departure
)内获得结束(arrival
)或开始(from
)(或两者)的预订。
答案 0 :(得分:3)
我认为可以使用filterexpression
来实现。
使用filterexpression的示例代码: -
const scanItem = Reservation.scan().filterExpression('room = :idVal AND ((arrival BETWEEN :arrDateVal1 AND :arrDateVal2) OR (departure BETWEEN :depDateVal1 AND :depDateVal2)) ')
.expressionAttributeValues({ ':idVal' : '2', ':arrDateVal1' : '21-APR-2017', ':arrDateVal2' : '23-APR-2017'
,':depDateVal1' : '21-APR-2017', ':depDateVal2' : '23-APR-2017'});
scanItem.exec((err, result) => {if(!err) {console.log(JSON.stringify(result,undefined, 2))}});
注意: - 强>
不确定是否要专门使用where
而不是filterexpression
(或)只是想要实现结果,而不管where
或filterexpression
。