Describe the issue:
I think the documentation for getting a filtered list of records in the cma might be incorrect.
I was trying to use the node client to get records published before a certain date with the _first_published_at
field.
I looked at the example code here: List all records — Record — Content Management API — DatoCMS
In the example it looks like you can add meta fields inside of the filter
object but outside of fields
.
import { buildClient } from "@datocms/cma-client-node";
async function run() {
// Make sure the API token has access to the CMA, and is stored securely
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const records = await client.items.list({
filter: {
type: "dog",
fields: {
name: {
in: ["Buddy", "Rex"],
},
breed: {
eq: "mixed",
},
},
_updated_at: {
gt: "2020-04-18T00:00:00",
},
},
order_by: "_updated_at_ASC",
});
console.log(records);
}
run();
But for me this no effect until I put it inside of fields
.
So this worked:
const records = await client.items.list({
page: { limit: 10 },
filter: {
type: "news_article",
fields: {
_first_published_at: {
lt: "2018-04-18T00:00:00",
},
},
},
order_by: "_first_published_at_DESC",
});
Might be a misunderstanding on my part though