Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion types/src/database_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use auth::UserGroup;
use chrono::{NaiveDate, NaiveDateTime};
use sqlx::postgres::types::PgLTree;
use sqlx::PgPool;
use std::ops::Bound;
use std::str::FromStr;
use user::UserUpdate;
Expand Down Expand Up @@ -32,7 +33,7 @@ use {
/// Connects to our backing database instance, providing high level functions
/// for accessing the data therein.
pub struct Database {
client: sqlx::Pool<sqlx::Postgres>,
pub client: sqlx::Pool<sqlx::Postgres>,
}
impl Database {
pub fn connect(num_connections: Option<u32>) -> Result<Self> {
Expand All @@ -49,6 +50,11 @@ impl Database {
Ok(Database { client: conn })
}

/// Add this new constructor for testing
pub fn with_pool(pool: PgPool) -> Self {
Database { client: pool }
}

/// Get a specific comment by id
pub async fn comment_by_id(&self, comment_id: &Uuid) -> Result<Comment> {
Ok(
Expand Down
Loading
Loading