Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.8k stars 104 forks source link

Nested create #44

Open Brendonovich opened 2 years ago

Brendonovich commented 2 years ago

The following should be possible:

client
    .user()
    .create(
        "Name".to_string(),
        user::image::create("some url".to_string(), vec![]),
    )
    .exec()
    .await;
hodlen commented 2 years ago

Hi! Is this feature in development or planned to be shipped recently? I am using this library to integrate with MongoDB, so nested creation is an essential feature to support my development.

I can see from the code, FieldTypeExt has not supported type(sub-docuemnt) for now.

Open to contributing some code here!

Brendonovich commented 2 years ago

From what I understand about MongoDB, I think you're referring to composite types. These are being tracked in #82. This issue is for creating records for a relation in a relational DB. Check #128 for the status on MongoDB support.

escwxyz commented 1 year ago

Hello, any update on this? Will there be any estimated date for this? Thanks.

Brendonovich commented 1 year ago

@linsijia628 Nothing yet. Rest assured I'm aware of it.

Brendonovich commented 8 months ago

still got a lot to go but the types for these are completed

client.user().create(
    "Brendan".to_string(),
    vec![user::posts::connect(vec![
        post::id::equals("0".to_string()),
        post::id::equals("1".to_string()),
    ])],
);

client.user().create(
    "Brendan".to_string(),
    vec![user::posts::create_many(vec![
        user::posts::create("Brendan".to_string(), false, vec![]),
        user::posts::create("Brendan".to_string(), true, vec![]),
    ])],
);

client.user().create(
    "Brendan".to_string(),
    vec![user::posts::connect_or_create([
        (
            post::id::equals("bruh".to_string()),
            user::posts::create("Brendan".to_string(), false, vec![]),
        ),
        (
            post::id::equals("bruh".to_string()),
            user::posts::create("Brendan".to_string(), true, vec![]),
        ),
    ])],
);