If anyone could shed some light on how to build a query in following format
results = await wixData.query( “…” )
.limit( 12 )
.find();
while (results.hasNext()) {
results = await results.next();
}
that outputs following table, that would be great:
I really cannot figure out how to properly use insertReference( ) for my entire database content from code .
Basically, I want to avoid having to query 12 items by chaining or statements like in below prototype. It works fine, but this shouldn’t be the way to do this.
results = await wixData.query("Collection_2")
.eq("_id", "e682d2b8-5411-4d61-92aa-ef371e58f8b2") //some _id in collection_2
.find()
console.log("results (1):")
console.log(results._items[0].Field_1);
//sort by match%
results._items[0].Field_1.sort((a, b) => (
parseFloat(b.Match)/100.0 > parseFloat(a.Match)/100.0
) ? 1 : -1) //descending - empty ones come first (ensure this doesn't happen)
console.log("results (2):")
console.log(results._items[0].Field_1);
//query 12 items
query = await wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[0].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[1].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[2].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[3].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[4].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[5].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[6].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[7].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[8].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[9].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[10].collectionId)
.or(
wixData.query("Collection_1")
.eq("_id", results._items[0].Field_1[11].collectionId)
)
)
)
)
)
)
)
)
)
)
)
.find()
console.log("results (3):")
console.log(query);
