Mike Rudge
06/13/2022, 7:37 PMPinkiePie
06/23/2022, 6:35 PMdb.Game.aggregate([{
$match: {
$expr: {
$and: [{
$in: ["$_id", [ObjectId("62b456c7548b0f401c499f49"), ObjectId("62b456e21955d39f37f9e45c"), ], ],
}, {
$or: [{
$ne: [{
$ifNull: ["$_id", null, ],
}, null, ],
}, {
$eq: ["$_id", null, ],
}, ],
}, ],
},
},
}, {
$project: {
_id: 1,
name: 1,
},
}, ])
_id
is a mandatory field, so it can't be null
, but we have a huge branch for it:
$or: [{
$ne: [{
$ifNull: ["$_id", null, ],
}, null, ],
}, {
$eq: ["$_id", null, ],
}, ],
PinkiePie
06/28/2022, 5:46 AMbulkWrite
with $runCommandRaw
?PinkiePie
06/28/2022, 6:02 AM$runCommandRaw
? input type Prisma.InputJsonObject
tells me nothing about which commands are supported and what kind of arguments they haveOctal pixel
06/28/2022, 3:59 PMMcKay Bonham
06/29/2022, 5:17 AMDmitri Pisarev
06/30/2022, 5:54 PMuserId String @map("user") @db.ObjectId
Now I’m trying to process this in my custom Prisma generator
plugin, and I need access to @map("user")
part.
But I don’t see it anywhere in the schema DMMF for this field:
{
name: 'userId',
kind: 'scalar',
isList: false,
isRequired: true,
isUnique: false,
isId: false,
isReadOnly: true,
type: 'String',
hasDefaultValue: false,
isGenerated: false,
isUpdatedAt: false
}
Is this a bug or a missing feature? I need this real bad (I’m building an automated $jsonSchema generator for Mongodb out of Prisma schema)
Basically I expected to see smth like dbName: 'user'
there.McKay Bonham
07/01/2022, 10:58 PMMcKay Bonham
07/03/2022, 2:12 PMlevel Int @default(2)
But the level attribute isn't getting populated at all when I make a new document of this type. Why is that?Dmitri Pisarev
07/05/2022, 6:52 AMPost.categories
relation. In inverse relation Category.posts
would explode the Category
entity, there would be hundreds of thousands of entries in it. Besides, it may eventually lead to inconsistent date if Post.categories
wouldn’t match Category.posts
for some reason.
So is there a way to only store the relation information on a Post
side and query things based only on it?
An alternative would be to get rid of m-n relations entirely and query for such relations manually. Which would be a shame of course.Dmitri Pisarev
07/06/2022, 11:00 AMezeikel
07/07/2022, 8:17 AMMcKay Bonham
07/07/2022, 7:15 PMprisma.parentDocument.update({
where: {
id: req.params.id
},
data: {
...req.body
},
select: {
childDocuments: true
}
});
, is there a way I can do all of these updates in one query?Maciej Błędkowski
07/15/2022, 7:33 PMVicente Matus
07/25/2022, 5:08 PMError: P1001
`Can't reach database server at `cluster0...`:`27019``
`Please make sure your database server is running at `cluster0...`:`27019`.`
Whenever i try to use npx prisma db pull
in an existing MongoDB data base
This is my DATABASE_URL
mongodb+srv://<username>:<password>@<cluster>/<database>?retryWrites=true&w=majority
I'm currently connected to MongoDB Atlas, and the cluster is allowing connections from all ip's. How can i solve this?ezeikel
07/25/2022, 7:48 PMDmitri Pisarev
07/27/2022, 12:47 PMUser {
groups: [{
groupId: 'group1-id',
membershipType: 'Member'
}, {
groupId: 'group2-id',
membershipType: 'Admin'
}]
}
I want User.groups.groupId
to be a relation. It’s currently not possible to set relationships on composite types.
Is there any workaround around this? Any better way to attach some attribute to a relationship?PlayWolfYT
08/04/2022, 10:20 AM<mongodb+srv://user:pass@xyz.mongodb.net/project>
does not work and
<mongodb://user:pass@shard-00-00.xyz.mongodb.net:27017>,<http://shard-00-01.xyz.mongodb.net:27017,shard-00-02.xyz.mongodb.net/project|shard-00-01.xyz.mongodb.net:27017,shard-00-02.xyz.mongodb.net/project>
doesPlayWolfYT
08/04/2022, 10:22 AMPlayWolfYT
08/08/2022, 11:24 AMmodel User {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
phone String? @unique()
}
As you can see, the phone number is optional and unique. Yet when I register a user without a phone number, I cannot register a second user without a phone number, as I get the error "Unique constraint failed on the constraint: 'User_phone_key' ".
Any way to say that null
is not a phone number and that it should not get counted as a unique value?Guro Khundadze
08/09/2022, 12:05 PMRuben
08/22/2022, 8:39 PMÖmer Genç
09/01/2022, 12:23 PMconst tags = [
{
id: '1111111',
name: 'big',
},
{
id: '2222222',
name: 'white',
},
{
id: '3333333',
name: 'expensive',
},
];
const products = [
{
id: 'aaaaaaaa',
name: 'dress',
price: 100,
tags: ['1111111', '2222222'],
},
{
id: 'bbbbbbbb',
name: 'dress 2',
price: 101,
tags: ['1111111', '3333333'],
},
];
I used many-to-many relation and result this.
const tags = [
{
id: '1111111',
name: 'big',
products: ['aaaaaa', 'bbbbbbb'],
},
{
id: '2222222',
name: 'white',
products: ['aaaaaa'],
},
{
id: '3333333',
name: 'expensive',
products: ['bbbbbbb'],
},
];
const products = [
{
id: 'aaaaaaaa',
name: 'dress',
price: 100,
tags: ['1111111', '2222222'],
},
{
id: 'bbbbbbbb',
name: 'dress 2',
price: 101,
tags: ['1111111', '3333333'],
},
];
this is my schema
model Product {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
tagIDs String[] @db.ObjectId
tags Tag2[] @relation(fields: [tagIDs], references: [id])
}
model Tag2 {
id String @id @default(auto()) @map("_id") @db.ObjectId
productIDs String[] @db.ObjectId
products Product[] @relation(fields: [productIDs], references: [id])
}
Thank you...Mohammed Almajid
09/08/2022, 12:36 AMproduction
the main issue is
P2023
"Inconsistent column data: {message}"
because I have some fields are unions , could be string or number
how to solve this issue ? is there anyway to tell prisma that field type could be string or number?
the solution that I have is to put field type as json
but is there better solution ?Andrew Obrigewitsch
09/08/2022, 7:52 PMcollection {
subCollections: [{address: "string"}]
}
I want to search by address.Sim Kai Chien
09/12/2022, 3:34 PMJake W
09/21/2022, 9:12 PMJake W
09/21/2022, 9:12 PMPrisma.member.findFirst()
invocation in`
/Users/jake/Desktop/neo-rewrite/src/utils/functions/clanning.ts:15:30
12 export const getMember = async (Guild: GuildType, Query: number | MemberType | string | APIInteractionGuildMember): Promise<MemberModel | null> => {
13 if (typeof Query === 'string') {
14 const userId = await getIdFromUsername(Query).catch(err => { return 0 })
→ 15 return await Prisma.member.findFirst(
Inconsistent column data: Malformed ObjectID: provided hex string representation must be exactly 12 bytes, instead got: "957114139052998716", length 18.
Raphael Etim
09/22/2022, 7:14 AMVladi Stevanovic
09/23/2022, 10:41 AM