Are there any examples of what the âtextual queryâ used in items.all() call might look like? The example provided only has the unfortunately obtuse filter[query]: "foo"
hello @glebdenisov, welcome
You are very right that we should improve our documentation. Meanwhile, what you can do is to use the CMS to filter and inspect the calls that we do in the browser to replicate them in your code.
An example that I can provide is:
filter[fields][title][matches][pattern]: some text
Let me know if the workaround is fine or if you need more details on a specific query.
Can you please update the examples to this instead ? filter[query]: "foo"
is not helpful.
hello @niko thank you for spotting that, it was actually a bug!
Please have a look now at the documentation: https://www.datocms.com/docs/content-management-api/resources/item/instances
hopefully itâs more helpful now.
@mat_jack1
I was trying to use the way you provide. but it isnât work
when I try with this, it work
const records = await client.items.all({
filter: {
type: âtestmodelâ,
fields: {
testtitle: {eq: âtest1â}
},
}
});
but when I tried this, itâs not working
client.items.all({
nested: âtrueâ,
âfilter[type]â: âtestmodelâ,
âfilter[fields][testtitle][eq]â: âtest2â,
âpage[offset]â: 2,
âpage[limit]â: 15,
})
Is there anything I did wrong?
Hey @jeff.f.chen I just tried and it works for me.
Can you maybe give me the real example with your project URL as well so that I can try? If you prefer send the info over at support@datocms.com
Thanks!
Sure,
Just PM you and also send my project URL to that email address.
Thank you!
Hi,
I am trying to list some records using the filter parameter on with a http request, but the documentation only provides examples for the Javascript client.
I tried your suggestion to get the filter[fields]...: some text
and encode it, but didnât work.
Could you give me an example on how I can use the filter parameter in http request?
Thanks in advance!
Hello @tiago
Here is an example:
Lets say you want to find a record in the model posts
that has a field title
with the value travel
you would run a
GET
https://site-api.datocms.com/items?filter[type]=posts&filter[fields][title][eq]=travel