You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you want to request a feature or report a bug?
bug What is the current behavior?
when you use a function to set a property value in schema it returns error If the current behavior is a bug, please provide the steps to reproduce.
import mongoose, { Schema, model, UpdateQuery } from 'mongoose';
async function run() {
mongoose.connect('mongodb://localhost:27017/test');
const UserModel = model('User', new Schema({
phone: { type: String, required: true, set: phoneNumberSetter },
name: String
}));
}
function phoneNumberSetter(phoneNumber: any, previousValue: any, self: any) {
let phone: string = phoneNumber;
if (typeof phoneNumber !== 'string') {
phone = self.cast(phoneNumber);
}
return phone;
}
What is the expected behavior?
it should not return an error
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: 14.17.4 , Mongoose: 6.0.7 , MongoDB: 4.4.3
The text was updated successfully, but these errors were encountered:
vkarpov15
added
typescript
Types or Types-test related issue / Pull Request
and removed
needs clarification
This issue doesn't have enough information to be actionable. Close after 14 days of inactivity
labels
Oct 1, 2021
Do you want to request a feature or report a bug?
bug
What is the current behavior?
when you use a function to set a property value in schema it returns error
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
it should not return an error
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: 14.17.4 , Mongoose: 6.0.7 , MongoDB: 4.4.3
The text was updated successfully, but these errors were encountered: