:tada: MongoDB introspection support is now in Pre...
# mongodb
v
šŸŽ‰ MongoDB introspection support is now in Preview Be sure to check the release notes!
šŸ™Œ 3
m
Very cool! Do we know how it handles existing embedded documents?
p
i'm sorry but without embedded documents, this feature is just a waste of time
j
coming soon the embedded documents
šŸ‘ 1
it is not obvious how to make them but it is priority #1
šŸ‘ 1
but release early, release often as they say
šŸ’Æ 2
m
So what happens with this introspection? Does it just ignore fields that are objects?
j
they're mapped as
Json
now, we have a sprint planning tomorrow, we'll start by introducing a new
type
construct in the data model, that can be used as embedded documents in mongo, but that work means the client must support this too, so I'd say the feature might not be in 3.3.0 still due to having a two team effort here
and this introspection is the first idea how it should be done, please report all bugs and ideas in the issue tracker so we know how you're using it
the interesting problems with introspecting embeds: • how do we name it, my idea is something like model name + field name • should we do deduplication, if two models have almost similar embeds, should we have two types or merge it to one • how would the naming work in the second example mongo introspection is quite best effort basis, we cannot do everything as we can with postgres for example
m
Yeah makes sense! I think something like transform.tools does a really good job of taking a JSON file and creating types. I would expect something like that.
j
yeah the types are not really my biggest issue here, but the naming
let's see, if we have
Copy code
{ name: "foo", data: { something: "bar" } }
so we can get the model name from the collection, but it will have one embed in the
data
Copy code
model User {
  name: String,
  data: UserData,
}

type UserData {
  something: String
}
this is still easy, but what if we have another model that has an embed with
{something: "bar"}
and we get into the model of deduplication
we either create many similar types, let the user to merge them, or implement deduplication where we merge similar types together
this gets also really hairy, the other embed might have
{ something: "foo", other: 2 }
, so we can have
Copy code
type UserData {
  something String,
  other Int?
}
but I think we go with the kind of dumb solution first, iterate from there
šŸ”„ 1
m
I hope this issue gets addressed soon. https://github.com/prisma/prisma/issues/8389