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

Support for references & population with Ref<M: Model> enum #10

Open
jonahseguin opened this issue Jan 21, 2023 · 1 comment
Open

Support for references & population with Ref<M: Model> enum #10

jonahseguin opened this issue Jan 21, 2023 · 1 comment
Assignees

Comments

@jonahseguin
Copy link
Member

pub enum Ref<M: Model> {
  Id(Id<M>),
  Model(M),
}

allow population with #[musty(mongo(populate))] field attributes, and possibly generate QueryOptions for each model, to allow for usage like so:

#[model(mongo)]
#[derive(Filter)]
struct User {
  id: Id<Self, u32>,
  address: Ref<Address>,
}

#[model(mongo)]
struct Address {
  id: Id<Self, u32>,
  street: String,
  city: String,
  country: String,
}

let user = User::get(
  &db, 
  User::filter().id().eq(1).build(), 
  User::options().address().populate(true).build()
).await?;
@jonahseguin jonahseguin self-assigned this Jan 21, 2023
jonahseguin added a commit that referenced this issue Jan 22, 2023
@jonahseguin
Copy link
Member Author

References done, population next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant