Add views field in the database
parent
aeacae85c3
commit
73b24a3a1c
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue