Make the REST API compatible with SQlite

This commit is contained in:
Bat
2018-09-29 18:14:48 +01:00
parent bd80430b1b
commit 07f2c979ec
2 changed files with 13 additions and 11 deletions
+6 -6
View File
@@ -57,10 +57,10 @@ pub struct NewPost {
pub source: String,
}
impl Provider<PgConnection> for Post {
impl Provider<Connection> for Post {
type Data = PostEndpoint;
fn get(conn: &PgConnection, id: i32) -> Result<PostEndpoint, Error> {
fn get(conn: &Connection, id: i32) -> Result<PostEndpoint, Error> {
Post::get(conn, id).map(|p| Ok(PostEndpoint {
id: Some(p.id),
title: Some(p.title.clone()),
@@ -69,7 +69,7 @@ impl Provider<PgConnection> for Post {
})).unwrap_or(Err(Error::NotFound("Get Post".to_string())))
}
fn list(conn: &PgConnection, filter: PostEndpoint) -> Vec<PostEndpoint> {
fn list(conn: &Connection, filter: PostEndpoint) -> Vec<PostEndpoint> {
let mut query = posts::table.into_boxed();
if let Some(title) = filter.title {
query = query.filter(posts::title.eq(title));
@@ -92,15 +92,15 @@ impl Provider<PgConnection> for Post {
).unwrap_or(vec![])
}
fn create(_conn: &PgConnection, _query: PostEndpoint) -> Result<PostEndpoint, Error> {
fn create(_conn: &Connection, _query: PostEndpoint) -> Result<PostEndpoint, Error> {
unimplemented!()
}
fn update(_conn: &PgConnection, _id: i32, _new_data: PostEndpoint) -> Result<PostEndpoint, Error> {
fn update(_conn: &Connection, _id: i32, _new_data: PostEndpoint) -> Result<PostEndpoint, Error> {
unimplemented!()
}
fn delete(conn: &PgConnection, id: i32) {
fn delete(conn: &Connection, id: i32) {
Post::get(conn, id).map(|p| p.delete(conn));
}
}