Update table field with Tailor

Hello, I’m new to OctoberCMS and I followed the YouTube video tutorial (https://www.youtube.com/watch?v=_WMH4mlMdjk). I would like to know if, while viewing a post, it is possible to update a certain field (views_count) in Blog\Post only with Tailor, since with the command below, I can search for records in the table:

{% set posts = blog.where('categories_id', 9).get() %}

Thank you very much in advance for any help :pray: :pray:

1 Like

Never tried, but here is the doc: Models - October CMS - 3.x


You might be able to do this in Twig:

{% do post.newQuery.update({ view_count: (post.view_count + 1) }) %}

This could be better since you only want to increment the number when the record is viewed on the frontend, rather than every time the record is fetched (model.afterFetch event).


Many thanks for the reply :pray: :pray: