Skip to content

Commit

Permalink
Remove project_id and database_id from firestore client
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 3, 2023
1 parent 0beeba1 commit b6dcd56
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions rust/crates/web/src/infra/firestore.rs
Expand Up @@ -37,32 +37,22 @@ pub enum Error {

pub struct Client {
client: FirestoreClient<GoogleAuthz<Channel>>,
database_id: String,
project_id: String,
}

impl Client {
// TODO: begin_transaction
// TODO: commit
// TODO: rollback

pub async fn new(
project_id: String,
database_id: String,
endpoint: &'static str,
) -> Result<Self, Error> {
pub async fn new(endpoint: &'static str) -> Result<Self, Error> {
let credentials = Credentials::builder().no_credentials().build().await?;
let channel = Channel::from_static(endpoint).connect().await?;
let channel = GoogleAuthz::builder(channel)
.credentials(credentials)
.build()
.await;
let client = FirestoreClient::new(channel);
Ok(Self {
client,
database_id,
project_id,
})
Ok(Self { client })
}

pub async fn create<T, U>(
Expand Down Expand Up @@ -216,12 +206,7 @@ mod tests {
let root_path = RootPath::new("demo-project1".to_string(), "(default)".to_string())?;
let collection_path = root_path.collection("repositories".to_string());

let mut client = Client::new(
collection_path.root().project_id().to_string(),
collection_path.root().database_id().to_string(),
endpoint,
)
.await?;
let mut client = Client::new(endpoint).await?;

// reset
let (documents, _) = client.list::<V>(&collection_path).await?;
Expand Down

0 comments on commit b6dcd56

Please sign in to comment.