![](/img/trans.png)
[英]Prisma2: how to design schema which has relation with Array type Model?
[英]Prisma: Is it possible to have a field on a model be an array of objects without any relation?
我的用戶 model 上有一個名為收藏夾的字段。 我希望這是一個對象數組。 我無法將字段設置為沒有某種關系或定義它的數組,但無法使用 object 定義它。 我也不能使用類型,因為我使用的是 PostgreSQL DB。 有什么辦法可以讓數組作為一個字段來接收對象,而該字段與另一個 model 沒有任何關系?
收藏夾字段中的一些虛擬數據示例
[ { id: 1, title: 'blah' }, { id: 2, title: 'ok' }, ]
我的架構:
model User { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt email String @unique firstName String lastName String password String playlists Playlist[] favorites Song[] }
我目前有與我不需要的歌曲 model 相關的收藏夾。 我只想讓收藏夾成為我存儲的對象數組,沒有任何關系。 就像是:
model User { favorites {}[] }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.