Add views field in the database

pull/1/head
kirbylife 2022-12-20 22:33:10 -06:00
parent aeacae85c3
commit 73b24a3a1c
3 changed files with 5 additions and 1 deletions

View File

@ -9,6 +9,7 @@ pub struct Post {
pub title: String, pub title: String,
pub content: String, pub content: String,
pub published: bool, pub published: bool,
pub views: i32,
pub created_at: NaiveDateTime, pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime, pub updated_at: NaiveDateTime,
} }
@ -19,4 +20,5 @@ pub struct NewPost {
pub title: String, pub title: String,
pub content: String, pub content: String,
pub published: bool, pub published: bool,
pub views: i32,
} }

View File

@ -1,9 +1,10 @@
table! { table! {
posts (id) { posts (id) {
id -> Int4, id -> Integer,
title -> Varchar, title -> Varchar,
content -> Text, content -> Text,
published -> Bool, published -> Bool,
views -> Integer,
created_at -> Timestamp, created_at -> Timestamp,
updated_at -> Timestamp, updated_at -> Timestamp,
} }

View File

@ -31,6 +31,7 @@
<label for="">Visible</label> <label for="">Visible</label>
<input name="published" type="checkbox" value="true"/> <input name="published" type="checkbox" value="true"/>
<textarea id="content" name="content"></textarea> <textarea id="content" name="content"></textarea>
<input name="views" type="number" value="0" style="display: none"/>
<button>Publicar</button> <button>Publicar</button>
</form> </form>
</div> </div>