Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collection mint query #39

Merged
merged 1 commit into from
Aug 2, 2023
Merged
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
1 change: 0 additions & 1 deletion core/src/collection_mints.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use holaplex_hub_nfts_solana_entity::{
collection_mints::{ActiveModel, Column, Entity, Model, Relation},

Check warning on line 2 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / Cargo Test

unused import: `Relation`

Check warning on line 2 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

unused import: `Relation`

Check warning on line 2 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

unused import: `Relation`

Check warning on line 2 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

unused import: `Relation`
collections,
};
use sea_orm::{prelude::*, JoinType, QuerySelect, Set};

Check warning on line 5 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / Cargo Test

unused imports: `JoinType`, `QuerySelect`

Check warning on line 5 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

unused imports: `JoinType`, `QuerySelect`

Check warning on line 5 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

unused imports: `JoinType`, `QuerySelect`

Check warning on line 5 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

unused imports: `JoinType`, `QuerySelect`

use crate::db::Connection;

pub struct CollectionMint;

impl CollectionMint {
pub async fn create(db: &Connection, model: Model) -> Result<Model, DbErr> {

Check warning on line 12 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

docs for function returning `Result` missing `# Errors` section
let conn = db.get();

let active_model: ActiveModel = model.into();
Expand All @@ -17,13 +17,13 @@
active_model.insert(conn).await
}

pub async fn find_by_id(db: &Connection, id: Uuid) -> Result<Option<Model>, DbErr> {

Check warning on line 20 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

docs for function returning `Result` missing `# Errors` section
let conn = db.get();

Entity::find().filter(Column::Id.eq(id)).one(conn).await
}

pub async fn update_owner_and_ata(

Check warning on line 26 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

docs for function returning `Result` missing `# Errors` section
db: &Connection,
model: &Model,
owner: String,
Expand All @@ -37,7 +37,7 @@
active_model.update(conn).await
}

pub async fn find_by_ata(db: &Connection, ata: String) -> Result<Option<Model>, DbErr> {

Check warning on line 40 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

docs for function returning `Result` missing `# Errors` section
let conn = db.get();

Entity::find()
Expand All @@ -46,21 +46,20 @@
.await
}

pub async fn find_by_id_with_collection(

Check warning on line 49 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

docs for function returning `Result` missing `# Errors` section
db: &Connection,
id: Uuid,
) -> Result<Option<(Model, Option<collections::Model>)>, DbErr> {
let conn = db.get();

Entity::find()
.join(JoinType::InnerJoin, Relation::Collections.def())
.find_also_related(collections::Entity)
.filter(Column::Id.eq(id))
.one(conn)
.await
}

pub async fn update(db: &Connection, model: ActiveModel) -> Result<Model, DbErr> {

Check warning on line 62 in core/src/collection_mints.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

docs for function returning `Result` missing `# Errors` section
let conn = db.get();

model.update(conn).await
Expand Down
Loading