Migration from properties to list
For example you have such old code. Saving product in price list
1
// we have array with products prices
2
var priceList = Bot.getProperty("priceList")
3
if(!priceList){ priceList = [] }
4
​
5
var curProduct = { name: 'Apple iPhone 25', price: 5100 }
6
global.push(priceList)
7
​
8
// we store all products in property preciList
9
Bot.setProperty("priceList", priceList, "json")
Copied!
And we can get products from list now:
1
​
2
Bot.sendMessage(priceList[0].name + ":" + priceList[0].price)
3
​
Copied!
This code is good for small priceList. But is very bad for large count of products (more then 200-500).
So we need migrate it to Lists
Saving product in price List:
1
Bot.setProperty({
2
name: 'Apple iPhone 25',
3
value: 5100,
4
type: 'float',
5
list: 'priceList' // bot list will be created if not exist
6
});
Copied!
And we can get sorted top list now:
1
let list = new List.new({ name: "priceList" })
2
​
3
let products = list.get(); // get first 100 (by default) products
4
​
5
Bot.sendMessage(products[0].name + ":" + products[0].price)
Copied!
Get next 100 products:
1
// get next 100 products:
2
let list = new List.new({ name: "priceList" })
3
list.page = 2;
4
let products = list.get(); // get first 100 (by default) products
5
​
6
Bot.sendMessage(products[0].name + ":" + products[0].price)
Copied!
Last modified 10mo ago
Copy link