add views filed in the database
parent
46007d9a32
commit
cca93aa1d8
|
@ -3,6 +3,8 @@ CREATE TABLE posts (
|
||||||
title VARCHAR NOT NULL,
|
title VARCHAR NOT NULL,
|
||||||
content TEXT NOT NULL,
|
content TEXT NOT NULL,
|
||||||
published BOOLEAN NOT NULL DEFAULT 'f',
|
published BOOLEAN NOT NULL DEFAULT 'f',
|
||||||
|
views integer NOT NULL DEFAULT 0,
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
table! {
|
// @generated automatically by Diesel CLI.
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
posts (id) {
|
posts (id) {
|
||||||
id -> Integer,
|
id -> Int4,
|
||||||
title -> Varchar,
|
title -> Varchar,
|
||||||
content -> Text,
|
content -> Text,
|
||||||
published -> Bool,
|
published -> Bool,
|
||||||
views -> Integer,
|
views -> Int4,
|
||||||
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"{% if post.published %}checked{% endif %}/>
|
<input name="published" type="checkbox" value="true"{% if post.published %}checked{% endif %}/>
|
||||||
<textarea id="content" name="content">{{ post.content }}</textarea>
|
<textarea id="content" name="content">{{ post.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