William GM
03/14/2022, 7:25 PMMounir Bennacer
03/14/2022, 8:14 PMMounir Bennacer
03/14/2022, 8:15 PMMounir Bennacer
03/14/2022, 8:16 PMprisma.$queryRaw
Mounir Bennacer
03/14/2022, 8:17 PMSELECT *
FROM IMPACTS
WHERE COMPANY_ID = 1
AND '[2020-01-01,2020-12-31]'::daterange @> during
GROUP BY 1
ORDER BY 1 ASC
Mounir Bennacer
03/14/2022, 8:18 PM{
"error": {
"code": "P2010",
"clientVersion": "3.10.0",
"meta": {
"code": "N/A",
"message": "error deserializing column 2: cannot convert between the Rust type `core::option::Option<alloc::string::String>` and the Postgres type `daterange`"
}
}
}
Lars Ivar Igesund
03/14/2022, 8:23 PMali
03/15/2022, 12:33 AMType 'string' is not assignable to type 'JsonNullableFilter'.
This is the query on Postgres. I have added filterJson
as a preview feature and run prisma generate. Is it supposed to be different?
my_users = await this.prisma.user.findMany({
where: {
metadata: Prisma.AnyNull,
},
})
Kenneth Gitere
03/15/2022, 7:40 AMPrismaClient
instance passed in the hooks.ts file so that all endpoints can access it but I get a warning after some time about having upto 10 instances running. Would it be better to just create a client instance within every endpoint?Kay Khan
03/15/2022, 12:07 PMexport const FindUsers = async (): Promise<ReturnType<typeof PrismaService.authentication.findMany> | null> => {
try {
const users = await PrismaService.authentication.findMany({
where: { dtype: "checkpoint_login" },
include: { user: true, authentication_permission: true },
});
return users
} catch (err) {
Logger.error({ method: "FindUsers", error: err, stack_trace: err.stack });
return null;
}
};
doesent work: ( im not sure why simplying returning a array breaks this.
export const FindUsers = async (): Promise<[ReturnType<typeof PrismaService.authentication.findMany> | null, null]> => {
try {
const users = await PrismaService.authentication.findMany({
where: { dtype: "checkpoint_login" },
include: { user: true, authentication_permission: true },
});
return [users, null];
} catch (err) {
Logger.error({ method: "FindUsers", error: err, stack_trace: err.stack });
return [null, err];
}
};
1. Type '(authentication & { user: user | null; authentication_permission: authentication_permission[]; })[]' is not assignable to type 'PrismaPromise<authentication[]>'.
Type '(authentication & { user: user | null; authentication_permission: authentication_permission[]; })[]' is missing the following properties from type 'Promise<authentication[]>': then, catch, finally, [Symbol.toStringTag]
I want to be able to return an array like above, as i generally call the function using:
const [usersData, usersError] = await FindUsers();
Ashwin Shenoy
03/15/2022, 1:35 PMClinton D'Annolfo
03/15/2022, 4:37 PMCristian Salamea
03/15/2022, 4:43 PMCristian Salamea
03/15/2022, 6:12 PMMischa
03/15/2022, 7:28 PMChip Clark
03/15/2022, 7:48 PMmodel Email {
EmailID Int @id @default(autoincrement()) @db.Int
EntityID? Int @db.Int
EntityTypeID Int @db.TinyInt
EmailAddress String @db.VarChar(50)
EmailTypeID Int @db.Int
Description String? @db.VarChar(100)
Active Boolean? @default(false) @db.Bit
ActiveFromDate DateTime @db.Date
ModifiedDate DateTime? @default(now()) @db.DateTime
ModifiedBy String @db.VarChar(30)
ValidFromDate DateTime? @db.DateTime2
ValidToDate DateTime? @db.DateTime2
EmailType EmailType? @relation(fields: [EmailTypeID], references: [EmailTypeID])
/// One to many relation with Person Entity through EntityID <-> PKPersonID
Person Person? @relation(fields: [EntityID], references: [PKPersonID])
}
Getting data isn't a problem, but when I try and Create a new email for an existing person:
JSON sent to API server
const tempEmailBody = {
'EntityID:': PKPersonID,
'EntityTypeID': 1,
'EmailAddress': email,
"ActiveFromDate": this.currentDate,
"ModifiedDate": this.currentDate,
"ModifiedBy": "MDD Admin Tool - modified",
'Active': true
}
I get an error:
Unknown arg `EntityID:` in data.EntityID: for type EmailCreateInput. Did you mean `EntityTypeID`? Available args:
type EmailCreateInput {
EntityTypeID: Int
EmailAddress: String
Description?: String | Null
Active?: Boolean | Null
ActiveFromDate: DateTime
ModifiedDate?: DateTime | Null
ModifiedBy: String
ValidFromDate?: DateTime | Null
ValidToDate?: DateTime | Null
EmailType?: EmailTypeCreateNestedOneWithoutEmailInput
Person?: PersonCreateNestedOneWithoutEmailInput
if I try and use Person
const tempEmailBody = {
'Person:': PKPersonID,
'EntityTypeID': 1,
'EmailAddress': email,
"ActiveFromDate": this.currentDate,
"ModifiedDate": this.currentDate,
"ModifiedBy": "MDD Admin Tool - modified",
'Active': true
}
I get the error:
Unknown arg `Person:` in data.Person: for type EmailCreateInput. Did you mean `Person`? Available args:
type EmailCreateInput {
EntityTypeID: Int
EmailAddress: String
Description?: String | Null
Active?: Boolean | Null
ActiveFromDate: DateTime
ModifiedDate?: DateTime | Null
ModifiedBy: String
ValidFromDate?: DateTime | Null
ValidToDate?: DateTime | Null
EmailType?: EmailTypeCreateNestedOneWithoutEmailInput
Person?: PersonCreateNestedOneWithoutEmailInput
}
IF I try and build something that creates a PersonWhereUniqueInput
const tempEmailBody = {
'Person:': {'PersonWhereUniqueInput': {PKPersonID: this.onePerson.PKPersonID} },
'EntityTypeID': 1,
'EmailAddress': email,
"ActiveFromDate": this.currentDate,
"ModifiedDate": this.currentDate,
"ModifiedBy": "MDD Admin Tool - modified",
'Active': true
}
I get the error:
Unknown arg `Person:` in data.Person: for type EmailCreateInput. Did you mean `Person`? Available args:
type EmailCreateInput {
EntityTypeID: Int
EmailAddress: String
Description?: String | Null
Active?: Boolean | Null
ActiveFromDate: DateTime
ModifiedDate?: DateTime | Null
ModifiedBy: String
ValidFromDate?: DateTime | Null
ValidToDate?: DateTime | Null
EmailType?: EmailTypeCreateNestedOneWithoutEmailInput
Person?: PersonCreateNestedOneWithoutEmailInput
}
Manthan Mallikarjun
03/15/2022, 8:27 PMaj
03/15/2022, 8:39 PMconnectOrCreate
where multiple fields match. Or how can I use where: {AND: [{},{}]}
operation inside connectOrCreate
?Mounir Bennacer
03/15/2022, 9:17 PMprisma.$queryRaw`
SELECT *
FROM MyTable
WHERE COMPANY_ID = 1
AND "[2020-01-01,2020-12-31]"::daterange @> during
GROUP BY 1
ORDER BY 1 ASC`
something like that where the date range is inclusive of bounds ( aka getting the whole day until 2020-12-31 000000 for say )Demian N
03/16/2022, 2:25 AMMoh
03/16/2022, 7:42 AMDamian M
03/16/2022, 8:17 AMctx.prisma[`${var)Model`].upsert(....
Typescript automatically creates a union with the variable possiblities but as these models have different fields I get an error like
Each member of the union type '(<T extends .... ..... => CheckSelect<...>)' has signatures, but none of those signatures are compatible with each other.
Is there anyway to fix this problem?Ludde Bror
03/16/2022, 11:42 AMconst newOrder = await prisma.Order.create({
data: {
// Hmm... How did the Order model look like again..? Do I really have to go to my schema to view it? can't it be shown in VS code when hovering "Order" or while typing?
},
});
Would you like me to create a feature request of this on github?Madhusha Prasad
03/16/2022, 12:16 PMMichael Roberts
03/16/2022, 12:26 PMRicardo Ferreira
03/16/2022, 12:44 PMCristian Salamea
03/16/2022, 1:42 PMJulien Goux
03/16/2022, 3:39 PMJulien Goux
03/16/2022, 4:04 PMBryson Kruk
03/16/2022, 5:37 PM