总的来说,我对Prisma和关系数据库很陌生。对于如何在表之间创建多到多的关系,特别是关系字段,我有点困惑。
例如,假设我想将这个数据库模型转换为Prisma模式。
这就是我想出的答案:
model User {
id String @id
comments Comment[]
posts Post[]
}
model Post {
id Int @default(autoincrement()) @id
author User
我正在尝试使用在端口4466上运行的本地prisma服务器运行prisma deploy,但是当我运行prisma deploy时,我收到以下消息
Authenticating...
Opening https://app.prisma.io/cli-auth?secret=$2a$08$u3VSbu6GSxSV8l86BFs24O in the browser
Could not open the authentication link, maybe this is an environment without a browser. Please open this url in your
我正在开发一些简单的Todo,使用NestJS和Prisma,并使用MongoDB作为DB。我使用的是一个免费和共享的MongoDB集群,它托管在MongoDB Altas云中。此外,我还将0.0.0.0/0添加到网络访问选项卡,这样任何人都可以连接到DB。
schema.prisma文件
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "mongodb"
我正在尝试用Prisma创建一个自动增量ID,但是当mongodb作为数据源时,auto ()函数并不存在。
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
sequence Int @unique @default(autoincrement()) // This doesn't work with mongodb
email String @unique
password String
createdAt Date
我刚开始用Prisma。以前主要是使用firebase和mongodb来定义我的模式。
我试图定义以下模式:
Vote {
id: ID!
from: User! # The user who voted
for: User! # The user that received a vote
rate: Float!
}
基本上,我想要实现的是让用户投票给其他用户(给他们一个分数)。比如说,在MongoDB中,我会创建一个单独的集合,如下所示:
{
id: DocumentID
from: String // id of the user who
考虑采用以下Prisma模式:
model Conversation {
id Int @id @default(autoincrement())
createdAt DateTime @db.Timestamp(6)
messages ConversationMessage[]
}
model ConversationMessage {
id Int @id @default(autoincr
我在理解Prisma中的关系和数据建模时遇到了问题。我有一个关于两个用户可以参与网球比赛的“简单”例子。所以我有:
Model User {
id Int @id
name String
}
Model Game {
id Int @id
player1 PlayerInGame
player2 PlayerInGame
}
Model PlayerInGame {
id Int @id
player User
game Game
}
它给出了这个错误:
Error validating mod
我正在使用mongodb v5.0.13
//schema.prisma
model Video {
id Int @id @map("_id")
title String
description String
tags Tag[]
}
model Tag {
id String @id @map("_id")
video Video? @relation(fields: [videoId], references: [id])
videoId
<div className={styles.Panier}>
<p onClick={()=>Quantity>0?NewItem(data,Quantity):console.log("Quantity must be more
than 0")}>Add To Cart</p>
</div>
单击该div时,将执行以下NewItem函数:
let NewItem = async (data,Qte) => {
const response = await fet
我正在使用Prisma,我想支持CASCADE删除,但是尽管我已经完成了文档中提到的所有事情,但我仍然没有让它开始工作。
这就是当我试图部署Prisma时所遇到的错误
Errors:
Restaurant
✖ The Mongo connector currently does not support Cascading Deletes, but the field `foods` defines cascade behavior. Please remove the onDelete argument.}
这是代码
type Restaurant {
id:
嗨,我有三个模特
model User {
user_id Int @id @default(autoincrement())
email String @unique
name String?
User_Account User_Account[]
}
model Account {
account_id Int @id @default (autoincrement()) @unique
email String
bank String
createdAt DateTime @default(now())
User_
误差Invalid "prisma.user.create()". Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set.
我在MongoDB/Express中使用了Nx ()和Prisma。
所以我第一次使用,我的提供者是 ,当我想创建一个模型时,它会抛出一个错误。
Invalid `prisma.user.create()` invocation:
Prisma needs to perform transactions, which requires your MongoDB server to be run
as a replica set. https://pris.ly/d/mongodb-replica-set
我在 应用程序中使用Prisma,并将代码放入API pages中。
我的DATABASE_URL是mongodb://localhost:270
我正在使用包prisma-offset-pagination应用分页。为此,我必须在我的代码中使用Prisma模型,这是怎么可能的:检查行: 02
const result = prismaOffsetPagination({
model: user, // How to access prisma model like in this example.
cursor: <cursor>,
size: 5,
buttonNum: 7,
orderBy: 'id',
orderDirection: 'desc
我使用命令“Prisma”对来自prisma的MongoDB进行了内省。这将将所有数字字段检测为整数(包括长字段和整数字段),并在prisma.schema中创建了以下条目:
Index Int // Here I search for something like 'Int32'
为了支持与32位应用程序的兼容性,我目前正在寻找一种方法来显式地将Int字段声明为32位整数--到目前为止还没有成功。数据库中尚未使用任何架构或类似的架构。
MongoDB和Prisma中数值数据类型的数据类型被描述为。
有谁知道明确声明这一点的方法吗?
我正在使用Prisma2+GraphQL,我想写schema.prisma
这是我下面的代码
model Message {
id Int @id @default(autoincrement())
text String
from User
to User
room Room
createdAt DateTime @default(now())
User User @relation("from", fields:[from], references:[id])
User User @relation("to", fields:
我有以下用户和组模型,它们共享多到多的关系:
model User {
id String @id @default(uuid())
email String @unique
groups UsersGroups[]
@@map("user")
}
model Group {
id String @id @default(uuid())
name String
users UsersGroups[]
@@map
我使用Prisma和一个Express后端和反应前端。我在邮递员上测试我的删除请求,我一直收到这个错误:
“\n无效的prisma.user.delete()调用:\n\n\n操作失败,因为它依赖一个或多个所需但未找到的记录。要删除的记录不存在。”
我查了他们的医生,除非我漏掉了什么-我真的找不到什么解释。我对关系数据库也相当陌生,这是我第一次使用Prisma。
我的模式非常长,所以我将发布相关部分:
model User {
id String @id
email String @unique
firstName
我正在尝试更新Prisma中的一对多关系。我的模式如下所示
model A_User {
id Int @id
username String
age Int
bio String @db.VarChar(1000)
createdOn DateTime @default(now())
features A_Features[]
}
model A_Features {
id Int @id @default(auto