prisma-client-rust icon indicating copy to clipboard operation
prisma-client-rust copied to clipboard

Nested create

Open Brendonovich opened this issue 2 years ago • 5 comments

The following should be possible:

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

Brendonovich avatar Apr 27 '22 21:04 Brendonovich

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!

hodlen avatar Sep 08 '22 12:09 hodlen

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.

Brendonovich avatar Sep 08 '22 14:09 Brendonovich

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

escwxyz avatar Mar 09 '23 08:03 escwxyz

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

Brendonovich avatar Mar 09 '23 11:03 Brendonovich

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![]),
        ),
    ])],
);

Brendonovich avatar Jan 02 '24 06:01 Brendonovich