Help, Schema types isn't having types applied (typescript) #9908
-
Heya! I used to use 5.11.12, and what I did work. I checked the change log, and in 5.11.15, mongoose was updated in regards to types, but this breaks a lotta stuff. Now, I could just use an old version or something, but that's for the weak. Anyways, I have this in my previous works: export interface IUser {
username: string,
password: string,
email:string
id: string,
}
export type SH = IUser & Document
const SH = new Schema({
username: {},
password: String,
email: String,
id: String
})
export const mod:Model<SH> = model<SH>("AuthUser", SH) Right, so that's great, but now, due to the absence of typescript docs, I can't figure out what to do, since it doesn't give type help, so I am assuming I'm doing something wrong? Thank you! Edit: So, I decided to deep dive straight into the types document in my local installation. After searching for quite a bit, I've ended up with the following code export interface IUser {
username: string,
password: string,
email:string
id: string,
}
export type SH = IUser & Document
const SH = new Schema<SH, Model<SH>, SH>({
username: {unique: true, type: String},
email: String,
password: String,
id: String,
}) Now, the problem there is that the username is actually giving of an error. I dug for the causes of the error, and found that its calling the type To clarify, the solution to the original question is that you needed to do |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solved,
|
Beta Was this translation helpful? Give feedback.
Solved,