Я использую JayData 1.3.5 Pro в своем приложении HTML5 для подключения к IndexDB.Улучшение производительности на фильтре Jaydata и toArray
У меня есть таблица PRODUCTS (contextEntity), и я использую следующий запрос для извлечения 15839 записей из одной таблицы.
dataContext.onReady(function() {
contextEntity
.filter(function (result) {
result.prod_num.toLowerCase.contains(this.prod_num) === -1 ||
result.vendor_name.toLowerCase.contains(this.vendor_name) === -1 ||
result.vendor_prod_num.toLowerCase.contains(this.vendor_prod_num) === -1 ||
result.desc1.toLowerCase.contains(this.desc1) === -1 ||
result.desc2.toLowerCase.contains(this.desc2) === -1 ||
result.desc3.toLowerCase.contains(this.desc3) === -1 ||
result.lookup.toLowerCase.contains(this.lookup) === -1 ||
result.icmastx_desc1.toLowerCase.contains(this.icmastx_desc1) === -1 ||
result.icmastx_desc5.toLowerCase.contains(this.icmastx_desc5) === -1 ||
result.icmastx_desc7.toLowerCase.contains(this.icmastx_desc7) === -1
},
{
prod_num: productPageProperty.search.toLowerCase(), // search input
vendor_name: productPageProperty.search.toLowerCase(),
vendor_prod_num: productPageProperty.search.toLowerCase(),
desc1: productPageProperty.search.toLowerCase(),
desc2: productPageProperty.search.toLowerCase(),
desc3: productPageProperty.search.toLowerCase(),
lookup: productPageProperty.search.toLowerCase(),
icmastx_desc1: productPageProperty.search.toLowerCase(),
icmastx_desc5: productPageProperty.search.toLowerCase(),
icmastx_desc7: productPageProperty.search.toLowerCase()
})
.toLiveArray(function (result) {
if (result != null && result.length > 0) {
result.forEach(function (item) {
productViewModel.push({
unit_conv: item.unit_conv,
cartid_sequence_num: null,
selling_disc: item.selling_disc,
pcat: item.pcat,
division_ck: item.division_ck,
uom: item.uom,
prod_num: item.prod_num,
desc1: item.desc1,
desc2: item.desc2,
net_avail: item.net_avail,
selling_price: item.selling_price,
cust_price: item.cust_price,
cust_disc: item.cust_disc,
qty_ordered: null,
extension: null
})
});
}
else {
productViewModel = [];
}
});
Теперь, что происходит, для поиска результатов поиска требуется 30 секунд. Есть ли способ оптимизировать этот код, чтобы я мог быстрее получить результаты поиска, как за 3 секунды. Я пытаюсь найти альтернативу для toArray/toLiveArray.
Просьба предложить альтернативный подход для повышения производительности.
Спасибо, Sriram