MongoDB: Collection with field with array content is not introspected with native type `@db.Array`
See original GitHub issueTake this collection:
[{
"_id": {
"$oid": "61e20bbc7fef3b66f439373a"
},
"name": "Sports",
"post_ids": [
{
"$oid": "61e20bbc7fef3b66f4393737"
}
]
},{
"_id": {
"$oid": "61e20bbd7fef3b66f439373b"
},
"name": "Fashion",
"post_ids": [
{
"$oid": "61e20bbc7fef3b66f4393737"
}
]
},{
"_id": {
"$oid": "61e20bbd7fef3b66f439373c"
},
"name": "Programming",
"post_ids": [
{
"$oid": "61e20bbc7fef3b66f4393737"
},
{
"$oid": "61e20bbc7fef3b66f4393739"
}
]
}]
Introspection result is:
model Category {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
name String @unique
post_ids String[] @db.ObjectId
}
But should be:
model Category {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
name String @unique
post_ids String[] @db.Array(ObjectId)
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Query an Array — MongoDB Manual
This page provides examples of query operations on array fields using the db.collection.find() method in mongosh . The examples on this page use...
Read more >How Prisma Introspects a Schema from a MongoDB Database
To fill in the fields with their type, we get a sample of up to 1000 random records from each collection and loop...
Read more >Avoid Unbounded Arrays — MongoDB Atlas
Storing arrays as field values allows you to model one-to-many or ... instead of across separate collections as you might in a relational...
Read more >$all — MongoDB Manual
When passed an array of a nested array (e.g. [ [ "A" ] ] ), $all matches documents where the field contains the...
Read more >How to query an array of objects to match any of the provided ...
You didnt get it. Indeed. I do not get it. The statement. foco_radiante: db.collection.findOne ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
See related internal discussion @matthewmueller: https://www.notion.so/prismaio/Design-discussion-the-Array-native-type-on-MongoDB-c67615379df6453d88d5d7b7e9768966
Closing this issue since introspection is working as expected. I’ll link to another issue if there’s more work to be done.