https://discord.gg/botpress logo
Schema declaration problem
# 🤝help
e
Hi I need to declare a Schema property of the type Array. My problem is that I don't find info on how to do so and actually I get an error. Here is my Schema structure zui.object({ dbID: zui.number(), websiteID: zui.number(), modelName: zui.string(), imgUrl: zui.string(), pageUrlFR: zui.string(), price: zui.number(), priceStr: zui.string(), signatureCollection: zui.boolean(), demoAvailable: zui.boolean(), view3DAvailable: zui.boolean(), customersFavourite: zui.boolean(), types: zui.array(), styles: zui.array() }) The 2 last properties gives me an error, but I don't know why or how to declare it. - Note that data in the array will be String - Also, I can't tell the size of the Array, it's based on the database data that can change over time. Any idea?
Found the problem, so I share the answer. We have to declare the type of items in the Array zui.object({ dbID: zui.number(), websiteID: zui.number(), modelName: zui.string(), imgUrl: zui.string(), pageUrlFR: zui.string(), price: zui.number(), priceStr: zui.string(), signatureCollection: zui.boolean(), demoAvailable: zui.boolean(), view3DAvailable: zui.boolean(), customersFavourite: zui.boolean(), types: zui.array(zui.string()), styles: zui.array(zui.string()) }) But also, what I get from the DB was a string that I had to split to get an Array modelObj.types.split(', ') Then assign it to the types in my variable object.
2 Views