So I have a collection blogs that has a published
field. I want to fetch all documents from the collection where the published
field is equal to true
. I tried to make an index with the published
field as part of the target values but apparently the index doesn’t work with Boolean datatypes.
The alternative solution I hacked together was making an index with published
as part of the values with ref
.
{
name: "blogs_get_published",
unique: false,
serialized: true,
source: "blogs",
values: [
{
field: ["ref"]
},
{
field: ["data", "published"]
}
]
}
Then using the following query, fetch all the items from the index, filter it and then fetch it.
Map(
Filter(
Paginate(Match(Index('blogs_get_published'))),
Lambda((ref, published) => published)
),
Lambda((ref, published) => q.Get(ref))
)
I wanted to ask if this is a good solution since I’m new to Fauna and FQL since at a first glance, it doesn’t seem super efficient in terms of TCOs. And is there a simpler way to fetch the documents with one attribute that is a Boolean?