Getting an array of dates from a Strapi query

Found the solution, so answering my own noob question here :sweat_smile:

I saved the response from the raw db query as a variable, and then used the js method .map() to return a new array with just the dates:

const rawDates = await strapi.connections.default.raw("SELECT published_at FROM posts WHERE author='1' ORDER BY published_at ASC"); 

const dates = rawDates.rows.map(row => row.published_at);

return dates;

I understand that querying the db directly like this is better performance wise, but just for learning purposes, what’s the strapi.query equivalent solution… using find/search?

2 Likes