Here is the code snippet,
const userSchema = new mongoose.Schema({
email: {
type: String,
required: true,
},
password: {
type: String,
required: true,
},
});
console.log(userSchema);
userSchema.statics.build = (user: UserAttrs) => {
return new User(user);
};
userSchema.pre("save", async function (next) {
if (this.isModified("password")) {
const hashed = await Password.toHash(this.get("password"));
this.set("password", hashed);
}
next();
});
Currently, I am encountering the following error message,
[auth] > <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cfaebabba78ffee1ffe1ff">[email protected]</a> start /app
[auth] > ts-node-dev src/index.ts
[auth]
[auth] [INFO] 12:46:59 ts-node-dev ver. 1.0.0 (using ts-node ver. 9.0.0, typescript ver. 3.9.7)
[auth] Compilation error in /app/src/models/user.ts
[auth] [ERROR] 12:47:04 ⨯ Unable to compile TypeScript:
[auth] src/models/user.ts(37,12): error TS2551: Property 'statics' does not exist on type 'Schema'. Did you mean 'static'?
[auth] src/models/user.ts(46,3): error TS2554: Expected 1 arguments, but got 0.
Even though the statics property is visible in the schema object when logged, the issue seems to be related to kubernetes and skaffold. Any suggestions on how to resolve this issue ??